filter playeer played
This commit is contained in:
1 parent
74e9285bac
commit
5081ec9e32
30 files changed
+4063
-1369
No files matched your search
@@ -2,71 +2,85 @@
|
||||
|
||||
namespace App\Actions\Selections;
|
||||
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Models\SofaScorePlayerPerSeason;
|
||||
use App\Models\StatistikoEvent;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
|
||||
class LoadPlayer
|
||||
{
|
||||
public static function load($get)
|
||||
public static function load(Get $get)
|
||||
{
|
||||
// $res = CompetitionGroup::with('country')->where('id', $league_id)->first();
|
||||
// $season_mode = $res->country->season_mode;
|
||||
|
||||
$team_id = $get('team_id');
|
||||
|
||||
$season = $get('season');
|
||||
|
||||
$res_details = StatistikoDetail::where('txodds_id', $team_id)->get();
|
||||
$team_position = $get('team_position');
|
||||
|
||||
if (! $res_details) {
|
||||
return [];
|
||||
$season_or_date = $filter['season_or_date'] ?? 'season';
|
||||
if($season_or_date != 'season' or !count($season)) {
|
||||
$season[] = date('Y');
|
||||
}
|
||||
|
||||
$player_ids = [];
|
||||
foreach ($res_details as $val) {
|
||||
$player_ids[] = $val->tm_player_id;
|
||||
}
|
||||
$res_player = StatistikoPlayer::whereIn('tm_player_id', $player_ids)
|
||||
->with('event')
|
||||
->where('minutes_played', '>', 0)
|
||||
->select('match_id','tm_player_id')
|
||||
->get();
|
||||
$counting = [];
|
||||
foreach ($res_player as $val) {
|
||||
if(in_array($val->event->season, $season)){
|
||||
$tm_player_id = $val->tm_player_id;
|
||||
if(!isset($counting[$tm_player_id])){
|
||||
$counting[$tm_player_id] = 1;
|
||||
}else {
|
||||
$counting[$tm_player_id]++;
|
||||
}
|
||||
}
|
||||
$matches = StatistikoEvent::where(function ($query) use ($team_id, $team_position) {
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
return $query->where('home_id', '=', $team_id);
|
||||
case 'away':
|
||||
return $query->where('away_id', '=', $team_id);
|
||||
default:
|
||||
return $query->where('home_id', '=', $team_id)
|
||||
->orWhere('away_id', '=', $team_id);
|
||||
}
|
||||
})->pluck('match_id')->toArray();
|
||||
|
||||
if (! $counting) {
|
||||
return [];
|
||||
}
|
||||
$matches_count = count($matches);
|
||||
|
||||
$colorlevel = round(max($counting)/3);
|
||||
$player = SofaScorePlayerPerSeason::with('details')->where('tx_team_id', $team_id)->whereIn('season', $season)->get();
|
||||
|
||||
$arr = [];
|
||||
foreach ($res_details as $val) {
|
||||
foreach ($player as $val) {
|
||||
|
||||
$tm_player_id = $val->tm_player_id;
|
||||
$position = strtoupper($val->position);
|
||||
|
||||
$matches_played = isset($counting[$tm_player_id]) ? $counting[$tm_player_id] : 0;
|
||||
if($matches_played < $colorlevel){
|
||||
$arr[$position][$val->tm_player_id] = '<span class="text-red-600">'.$val->name.' ('.$matches_played.')</span>';
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
$events_played = $val->events_played_home;
|
||||
break;
|
||||
case 'away':
|
||||
$events_played = $val->events_played_away;
|
||||
break;
|
||||
default:
|
||||
$events_played = $val->events_played_home + $val->events_played_away;
|
||||
break;
|
||||
}
|
||||
else if($matches_played < $colorlevel*2){
|
||||
$arr[$position][$val->tm_player_id] = '<span class="text-blue-500">'.$val->name.' ('.$matches_played.')</span>';
|
||||
|
||||
$colorlevel = round($matches_count/3);
|
||||
|
||||
$position = strtoupper($val->details->position);
|
||||
|
||||
if($events_played < $colorlevel){
|
||||
$arr[$position][$val->tm_player_id] = '<span class="text-red-600 dark:text-red-500">'.$val->details->name.' ('.$events_played.')</span>';
|
||||
}
|
||||
else if($events_played < $colorlevel*2){
|
||||
$arr[$position][$val->tm_player_id] = '<span class="text-blue-600 dark:text-blue-500">'.$val->details->name.' ('.$events_played.')</span>';
|
||||
}
|
||||
else {
|
||||
$arr[$position][$val->tm_player_id] = '<span class="text-green-500">'.$val->name.' ('.$matches_played.')</span>';
|
||||
$arr[$position][$val->tm_player_id] = '<span class="text-green-600 dark:text-green-500">'.$val->details->name.' ('.$events_played.')</span>';
|
||||
}
|
||||
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function convertToHoursMins(int $time, $format = '%02dh:%02dm')
|
||||
{
|
||||
if ($time < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$hours = floor($time / 60);
|
||||
$minutes = $time % 60;
|
||||
|
||||
return sprintf($format, $hours, $minutes);
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class Sofascore
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(Nuh::$options['sport'].' '.Nuh::$options['name'], 'bb');
|
||||
Notice::note(Nuh::$options['sport'] ?? 'All'.' '.Nuh::$options['name'], 'bb');
|
||||
}
|
||||
|
||||
switch (Nuh::$options['name']) {
|
||||
|
||||
@@ -92,14 +92,14 @@ class EventsDatabase
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder.'/statistics.json', json_encode($data));
|
||||
|
||||
/*********************************
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/lineups";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
@@ -110,14 +110,14 @@ class EventsDatabase
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder.'/lineups.json', json_encode($data));
|
||||
|
||||
/*********************************
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/odds/1/all";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
@@ -128,6 +128,8 @@ class EventsDatabase
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder.'/odds.json', json_encode($data));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,129 +2,31 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore\Specials\CountPlayerPerSeason;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
ini_set('magic_quotes_runtime', false);
|
||||
|
||||
class Special
|
||||
{
|
||||
public static $max_days = 30;
|
||||
|
||||
public static Carbon $days_back;
|
||||
|
||||
public static $storage_path = '/Console/Commands/Grapper/Sofascore/worldcup-teams/';
|
||||
|
||||
public static function load()
|
||||
{
|
||||
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$url = Nuh::$options['base_url'].'/api/v1/world-cup/meet-the-team';
|
||||
$special = Nuh::$options['special'];
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
switch($special){
|
||||
case 1:
|
||||
if($debug){
|
||||
Notice::note("Sleep $rand msec", 'y');
|
||||
}
|
||||
usleep($rand);
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
$teams = [];
|
||||
|
||||
foreach ($data['groups'] as $groups) {
|
||||
foreach ($groups['teams'] as $team) {
|
||||
$teams[] = [
|
||||
'id' => $team['team']['id'],
|
||||
'slug' => $team['team']['slug'],
|
||||
'name' => $team['team']['name'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($teams as $team) {
|
||||
|
||||
Nuh::$options['s'] = 0;
|
||||
|
||||
Nuh::$options['r'] = 0;
|
||||
|
||||
$url = 'https://www.sofascore.com/api/v1/team/'.$team['id'].'/events/last/0';
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
foreach ($data['events'] as $event) {
|
||||
// "id" => 12749524
|
||||
// "slug" => "mexico-usa"
|
||||
// "startTimestamp" => 1729045800
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
/*********************************
|
||||
* Folder
|
||||
*********************************/
|
||||
|
||||
$starttime = Carbon::createFromTimestamp($event['startTimestamp'])->format('Y-m-d');
|
||||
|
||||
$folder = app_path().self::$storage_path.$starttime.'/'.$event['tournament']['slug'].'/'.$event['slug'];
|
||||
|
||||
File::makeDirectory($folder, 0775, true, true);
|
||||
|
||||
/*********************************
|
||||
* EVENT event basic
|
||||
*********************************/
|
||||
|
||||
File::put($folder.'/event.json', json_encode($event));
|
||||
|
||||
/*********************************
|
||||
* EVENT statistics
|
||||
*********************************/
|
||||
|
||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/statistics";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
if ($debug) {
|
||||
Notice::note("Sleep $rand msec", 'y');
|
||||
}
|
||||
usleep($rand);
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
File::put($folder.'/statistics.json', json_encode($data));
|
||||
|
||||
/*********************************
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/lineups";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
if ($debug) {
|
||||
Notice::note("Sleep $rand msec", 'y');
|
||||
}
|
||||
usleep($rand);
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
File::put($folder.'/lineups.json', json_encode($data));
|
||||
|
||||
/*********************************
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
$event_id = $event['id'];
|
||||
|
||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/odds/1/all";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
if ($debug) {
|
||||
Notice::note("Sleep $rand msec", 'y');
|
||||
}
|
||||
usleep($rand);
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
File::put($folder.'/odds.json', json_encode($data));
|
||||
Notice::note('For speed in Statistiko'.PHP_EOL.'Count for every player how many time he has player per season and write it to DB', 'g');
|
||||
}
|
||||
CountPlayerPerSeason::run();
|
||||
break;
|
||||
default:
|
||||
Notice::note('special ID not set process stopped', 'br', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore\Specials;
|
||||
|
||||
use App\Models\SofaScorePlayerPerSeason;
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoPlayer;
|
||||
|
||||
class CountPlayerPerSeason
|
||||
{
|
||||
public static function run()
|
||||
{
|
||||
$res = StatistikoDetail::query()->select('tm_player_id', 'txodds_id')->get();
|
||||
|
||||
foreach ($res as $val) {
|
||||
|
||||
$collection = [];
|
||||
|
||||
$res2 = StatistikoPlayer::with('event')->where('tm_player_id', $val->tm_player_id)->get();
|
||||
|
||||
foreach ($res2 as $val2) {
|
||||
|
||||
if(!isset($collection[$val2->event->season])){
|
||||
$collection[$val2->event->season]['events_played_home'] = 0;
|
||||
$collection[$val2->event->season]['events_played_away'] = 0;
|
||||
$collection[$val2->event->season]['minutes_played_home'] = 0;
|
||||
$collection[$val2->event->season]['minutes_played_away'] = 0;
|
||||
}
|
||||
if($val2->minutes_played > 0){
|
||||
if($val->txodds_id == $val2->event->home_id){
|
||||
$collection[$val2->event->season]['events_played_home'] += 1;
|
||||
$collection[$val2->event->season]['minutes_played_home'] += $val2->minutes_played;
|
||||
}
|
||||
else if($val->txodds_id == $val2->event->away_id){
|
||||
$collection[$val2->event->season]['events_played_away'] += 1;
|
||||
$collection[$val2->event->season]['minutes_played_away'] += $val2->minutes_played;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($collection as $season => $row) {
|
||||
if($val->txodds_id && $val->tm_player_id){
|
||||
SofaScorePlayerPerSeason::updateOrCreate(
|
||||
[
|
||||
'tm_player_id' => $val->tm_player_id,
|
||||
'tx_team_id' => $val->txodds_id,
|
||||
'season' => $season
|
||||
],
|
||||
[
|
||||
'events_played_home' => $row['events_played_home'],
|
||||
'events_played_away' => $row['events_played_away'],
|
||||
'minutes_played_home' => $row['minutes_played_home'],
|
||||
'minutes_played_away' => $row['minutes_played_away'],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ class Nuh extends Command
|
||||
|
||||
public static $id = 0;
|
||||
|
||||
protected $signature = 'nuh {process=help} {--truncate} {--groups=0} {--days=0} {--day=0} {--id=0} {--fn=} {--gid=} {--p} {--d} {--x} {--t} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e} {--z}';
|
||||
protected $signature = 'nuh {process=help} {--truncate} {--groups=0} {--days=0} {--day=0} {--id=0} {--special=0} {--fn=} {--gid=} {--p} {--d} {--x} {--t} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e} {--z}';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
@@ -51,6 +51,7 @@ class Nuh extends Command
|
||||
$txt .= '--days (optional) grap days back from yesterday' . PHP_EOL;
|
||||
$txt .= '--groups (optional) csv of tournament_id\'s' . PHP_EOL;
|
||||
$txt .= '--p will print days and tournaments and stop' . PHP_EOL;
|
||||
$txt .= '--special (generate data) [1 => count played/season]' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL . PHP_EOL;
|
||||
$txt .= 'Options' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSofaScoreDay extends CreateRecord
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSofaScoreDays extends ListRecords
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Schemas;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreDays;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages\ListSofaScoreDays;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Schemas\SofaScoreDayForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Tables\SofaScoreDaysTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Filament\Clusters\Grapper\GrapperCluster;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Pages\ListSofaScoreDays;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Schemas\SofaScoreDayForm;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Tables\SofaScoreDaysTable;
|
||||
use App\Models\SofaScoreDay;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -22,7 +22,7 @@ class SofaScoreDayResource extends Resource
|
||||
|
||||
protected static ?string $navigationLabel = 'Days';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
protected static ?string $cluster = GrapperCluster::class;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
+31
-2
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Tables;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Tables;
|
||||
|
||||
use App\Models\SofaScoreDay;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
@@ -14,6 +16,7 @@ use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class SofaScoreDaysTable
|
||||
@@ -104,7 +107,33 @@ class SofaScoreDaysTable
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->persistFiltersInSession()
|
||||
->deferFilters(false);
|
||||
->deferFilters(false)
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('Enable')
|
||||
->icon('phosphor-toggle-right-fill')
|
||||
->color('primary')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
SofaScoreDay::where('id', '=', $record->id)
|
||||
->update(
|
||||
['enabled' => 1]
|
||||
);
|
||||
}
|
||||
}),
|
||||
BulkAction::make('Disable')
|
||||
->icon('phosphor-toggle-left-fill')
|
||||
->color('gray')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
SofaScoreDay::where('id', '=', $record->id)
|
||||
->update(
|
||||
['enabled' => 0]
|
||||
);
|
||||
}
|
||||
}),
|
||||
])->label('Grapping Day'),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function years()
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSofaScoreTournament extends CreateRecord
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Schemas;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages\ListSofaScoreTournaments;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Schemas\SofaScoreTournamentForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables\SofaScoreTournamentsTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Filament\Clusters\Grapper\GrapperCluster;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Pages\ListSofaScoreTournaments;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Schemas\SofaScoreTournamentForm;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Tables\SofaScoreTournamentsTable;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -19,7 +19,7 @@ class SofaScoreTournamentResource extends Resource
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
protected static ?string $cluster = GrapperCluster::class;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'Tournaments';
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Tables;
|
||||
|
||||
use App\Models\SofaScoreCategorie;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\SofaScoreDayTournamentResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSofaScoreDayTournament extends CreateRecord
|
||||
{
|
||||
protected static string $resource = SofaScoreDayTournamentResource::class;
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\SofaScoreDayTournamentResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSofaScoreDayTournament extends EditRecord
|
||||
{
|
||||
protected static string $resource = SofaScoreDayTournamentResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\SofaScoreDayTournamentResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSofaScoreDayTournaments extends ListRecords
|
||||
{
|
||||
protected static string $resource = SofaScoreDayTournamentResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class SofaScoreDayTournamentForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Pages\CreateSofaScoreDayTournament;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Pages\EditSofaScoreDayTournament;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Pages\ListSofaScoreDayTournaments;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Schemas\SofaScoreDayTournamentForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Tables\SofaScoreDayTournamentsTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use Livewire\Livewire;
|
||||
use UnitEnum;
|
||||
|
||||
class SofaScoreDayTournamentResource extends Resource
|
||||
{
|
||||
protected static bool $shouldRegisterNavigation = false;
|
||||
|
||||
protected static ?string $model = SofaScoreDayTournament::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'Days & Tournaments';
|
||||
|
||||
protected static ?string $navigationLabel = 'Days & Tournaments';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return SofaScoreDayTournamentForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return SofaScoreDayTournamentsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListSofaScoreDayTournaments::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
// return parent::getEloquentQuery()->count();
|
||||
// Ensure we are on the list page
|
||||
if (! class_exists(Livewire::class) || Livewire::current() === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$livewire = Livewire::current();
|
||||
|
||||
// Check if the current component has the table filtering traits
|
||||
if (method_exists($livewire, 'getFilteredTableQuery')) {
|
||||
return (string) $livewire->getFilteredTableQuery()->count();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class SofaScoreDayTournamentsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
//
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,10 @@ class Statistic extends BaseDashboard
|
||||
'all' => 'All',
|
||||
'home' => 'Home',
|
||||
'away' => 'Away',
|
||||
]),
|
||||
])->afterStateUpdated(function (callable $set) {
|
||||
// $set('team_id', null);
|
||||
$set('tm_player_id', null);
|
||||
}),
|
||||
]),
|
||||
Grid::make([
|
||||
'default' => 1,
|
||||
@@ -220,15 +223,6 @@ class Statistic extends BaseDashboard
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->prefixIconColor(fn(Get $get): string => $get('similar_past_matches') == 'none' ? 'primary' : '')
|
||||
->prefixIcon('icon-player')
|
||||
->suffixAction(
|
||||
Action::make('copyCostToPrice')
|
||||
->action(function (callable $set) {
|
||||
$set('tm_player_id', null);
|
||||
$set('player_on_field', null);
|
||||
})
|
||||
->color('gray')
|
||||
->icon('phosphor-x'),
|
||||
)
|
||||
->preload()
|
||||
->searchable()
|
||||
->options(function (Get $get) {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Filament\Widgets\Data;
|
||||
|
||||
use App\Filament\Widgets\Data\LoadEvents\LoadEventsAverages;
|
||||
use App\Models\SofaScoreEvent;
|
||||
use App\Models\SofaScorePlayerPerSeason;
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoEvent;
|
||||
@@ -95,9 +97,25 @@ class LoadEvents
|
||||
*/
|
||||
$matches_played = [];
|
||||
$description = '';
|
||||
// dd($tm_player_id); 613873
|
||||
|
||||
if ($tm_player_id) {
|
||||
$matches_played = StatistikoPlayer::where('tm_player_id', (int) $tm_player_id)
|
||||
|
||||
$matches_season = StatistikoEvent::where(function ($query) use ($team_id, $team_position) {
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
return $query->where('home_id', '=', $team_id);
|
||||
case 'away':
|
||||
return $query->where('away_id', '=', $team_id);
|
||||
default:
|
||||
return $query->where('home_id', '=', $team_id)
|
||||
->orWhere('away_id', '=', $team_id);
|
||||
}
|
||||
})->pluck('match_id')->toArray();
|
||||
|
||||
|
||||
$matches_played = StatistikoPlayer::query()
|
||||
->whereIn('match_id', $matches_season)
|
||||
->where('tm_player_id', '=', (int) $tm_player_id)
|
||||
->when($player_on_field, function ($query) use ($player_on_field) {
|
||||
// 'all' => 'All',
|
||||
// 'lineup' => 'Lineup',
|
||||
@@ -105,16 +123,18 @@ class LoadEvents
|
||||
// 'notplayed' => 'Not Played',
|
||||
switch ($player_on_field) {
|
||||
case 'all':
|
||||
return $query->where('match_id', '>', 0);
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
case 'lineup':
|
||||
return $query->where('lineup', 'T');
|
||||
return $query->where('lineup', 'T')->where('minutes_played', '>', 0);
|
||||
case 'substituted':
|
||||
return $query->where('lineup', 'P');
|
||||
case 'notplayed':
|
||||
return $query->where('lineup', '=', '');
|
||||
return $query->where('lineup', 'P')->where('minutes_played', '>', 0);
|
||||
default:
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
}
|
||||
})
|
||||
->pluck('match_id')->toArray();
|
||||
|
||||
|
||||
$description = ' with ' . StatistikoDetail::where('tm_player_id', (int) $tm_player_id)->value('name') . ' (' . \count($matches_played) . ')';
|
||||
|
||||
if (! $matches_played) {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SofaScorePlayerPerSeason extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'tm_player_id',
|
||||
'tx_team_id',
|
||||
'season',
|
||||
'events_played_home',
|
||||
'events_played_away',
|
||||
'minutes_played_home',
|
||||
'minutes_played_away',
|
||||
];
|
||||
|
||||
public function details()
|
||||
{
|
||||
return $this->belongsTo(StatistikoDetail::class, 'tm_player_id', 'tm_player_id');
|
||||
}
|
||||
}
|
||||
@@ -39,4 +39,9 @@ class StatistikoDetail extends Model
|
||||
'last_update' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function season()
|
||||
{
|
||||
return $this->hasMany(SofaScorePlayerPerSeason::class, 'tm_player_id', 'tm_player_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('sofa_score_player_per_seasons', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('tm_player_id')->index();
|
||||
$table->integer('tx_team_id')->index();
|
||||
$table->string('season')->index();
|
||||
$table->integer('events_played_home')->default(0)->nullable();
|
||||
$table->integer('events_played_away')->default(0)->nullable();
|
||||
$table->integer('minutes_played_home')->default(0)->nullable();
|
||||
$table->integer('minutes_played_away')->default(0)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sofa_score_player_per_seasons');
|
||||
}
|
||||
};
|
||||
+3776
-1005
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user