From 9214da8a1541b0236add6f944ee937de53493e33 Mon Sep 17 00:00:00 2001 From: salam Date: Wed, 24 Jun 2026 15:56:43 +0200 Subject: [PATCH] changes to grapper wip --- app/Console/Commands/Grapper/Sofascore.php | 30 ++- .../Commands/Grapper/Sofascore/.gitignore | 3 +- .../Commands/Grapper/Sofascore/Events.php | 71 +++---- .../Grapper/Sofascore/EventsDatabase.php | 137 +++++++++++++ .../Commands/Grapper/Sofascore/Special.php | 26 +-- .../Supervisors/Tables/SupervisorsTable.php | 10 +- .../Tables/SofaScoreDaysTable.php | 81 +++++--- .../Tables/SofaScoreTournamentsTable.php | 184 +++++++++--------- composer.lock | 104 ++++++++-- 9 files changed, 445 insertions(+), 201 deletions(-) create mode 100644 app/Console/Commands/Grapper/Sofascore/EventsDatabase.php diff --git a/app/Console/Commands/Grapper/Sofascore.php b/app/Console/Commands/Grapper/Sofascore.php index f2d00bf7..d780617c 100644 --- a/app/Console/Commands/Grapper/Sofascore.php +++ b/app/Console/Commands/Grapper/Sofascore.php @@ -3,6 +3,7 @@ namespace App\Console\Commands\Grapper; use App\Console\Commands\Grapper\Sofascore\Events; +use App\Console\Commands\Grapper\Sofascore\EventsDatabase; use App\Console\Commands\Grapper\Sofascore\Special; use App\Console\Commands\Grapper\Sofascore\Tournament; use App\Console\Commands\Nuh; @@ -17,8 +18,11 @@ use Illuminate\Support\Carbon; class Sofascore { public static $auth_header = []; + public static $base_url = ''; + public static $_days = []; + public static $sport = [1]; public static function switch() @@ -35,13 +39,14 @@ class Sofascore if (Nuh::$options['t']) { self::$_days[] = Carbon::now()->format('Y-m-d'); - } else if (Nuh::$options['day']) { - if (self::validateDate(Nuh::$options['day'])) { - self::$_days[] = Nuh::$options['day']; + } elseif (Nuh::$options['day']) { + $day = self::validateDate(Nuh::$options['day']); + if ($day) { + self::$_days[] = $day; } else { - Notice::note('date not valid ' . Nuh::$options['day'], 'r', 1); + Notice::note('date not valid '.Nuh::$options['day'], 'r', 1); } - } else if (Nuh::$options['days']) { + } elseif (Nuh::$options['days']) { $to = Carbon::now()->subDays(Nuh::$options['days']); $from = Carbon::now()->subDay(); while ($from >= $to) { @@ -51,9 +56,9 @@ class Sofascore } if ($debug) { - Notice::note(Nuh::$options['sport'] . ' ' . Nuh::$options['name'], 'bb'); + Notice::note(Nuh::$options['sport'].' '.Nuh::$options['name'], 'bb'); } - + switch (Nuh::$options['name']) { case 'TOURNAMENTS': Tournament::load(); @@ -61,6 +66,9 @@ class Sofascore case 'EVENTS': Events::load(); break; + case 'EVENTSDB': + EventsDatabase::load(); + break; case 'SPECIAL': Special::load(); break; @@ -73,7 +81,13 @@ class Sofascore public static function validateDate($date, $format = 'Y-m-d') { + if (is_numeric($date)) { + $date = date('Y').'-'.date('m').'-'.$date; + } $d = DateTime::createFromFormat($format, $date); - return $d && $d->format($format) == $date; + + if ($d && $d->format($format) == $date) { + return $d->format($format); + } } } diff --git a/app/Console/Commands/Grapper/Sofascore/.gitignore b/app/Console/Commands/Grapper/Sofascore/.gitignore index 065b0483..0dbecae5 100644 --- a/app/Console/Commands/Grapper/Sofascore/.gitignore +++ b/app/Console/Commands/Grapper/Sofascore/.gitignore @@ -1,2 +1 @@ -/grapped -/worldcup-teams \ No newline at end of file +/grapped \ No newline at end of file diff --git a/app/Console/Commands/Grapper/Sofascore/Events.php b/app/Console/Commands/Grapper/Sofascore/Events.php index e65aa164..2a551407 100644 --- a/app/Console/Commands/Grapper/Sofascore/Events.php +++ b/app/Console/Commands/Grapper/Sofascore/Events.php @@ -2,7 +2,6 @@ namespace App\Console\Commands\Grapper\Sofascore; -use App\Console\Commands\Grapper\Sofascore; use App\Console\Commands\Nuh; use App\Models\SofaScoreDayTournament; use App\Utilities\Notice; @@ -18,20 +17,20 @@ class Events $debug = Nuh::$options['d'] ?? 0; $print = Nuh::$options['p'] ?? 0; $sport_id = Nuh::$options['sport_id']; + $dback = Nuh::$options['days'] ?? 1; - $singleday = Nuh::$options['day'] ?? 0; - if($singleday){ + if ($singleday) { $dback = 1; } - if($print){ + if ($print) { for ($i = 1; $i <= $dback; $i++) { $day = Carbon::now()->subDays($i)->format('Y-m-d'); if ($debug) { Notice::note($day, 'p'); } - if(Nuh::$options['groups']){ + if (Nuh::$options['groups']) { $tornaments = explode(',', Nuh::$options['groups']) ?? 0; $ss_days = SofaScoreDayTournament::with('tournament') ->when($tornaments, function ($query) use ($tornaments) { @@ -52,38 +51,22 @@ class Events * finland veikkaus => 41 */ $tornaments = explode(',', Nuh::$options['groups']) ?? 0; - - - // for ($i = 1; $i <= $dback; $i++) { - // // remove one day to start yesterday - // $day = Carbon::now()->subDays($i)->format('Y-m-d'); - // if ($debug) { - // Notice::note($day, 'p'); - // } - // $ss_days = SofaScoreDayTournament::with('tournament') - // ->when($tornaments, function ($query) use ($tornaments) { - // return $query->whereIn('tournament_id', $tornaments); - // }) - // ->whereHas('tournament', function ($query) use ($sport_id) { - // $query->where('sport_id', $sport_id); - // }) - // ->where('day', $day)->get(); - // foreach ($ss_days as $ss_day) { - // $sofa_score_categorie_id = $ss_day->tournament->sofa_score_categorie_id; - // // https://www.sofascore.com/api/v1/unique-tournament/16/scheduled-events/2026-06-19 - // $url = Nuh::$options['base_url'] . "api/v1/category/$sofa_score_categorie_id/scheduled-events/$day"; - // Notice::note($url, 'p'); - // } - // } - // exit; + if (array_sum($tornaments)) { + if ($debug) { + Notice::note('groups and day(s) used from comandline', 'p'); + } + if (! Nuh::$options['days'] or ! Nuh::$options['day']) { + Notice::note('no day(s) option in comandline (--day=1)', 'r', 1); + } + } for ($i = 1; $i <= $dback; $i++) { - + // remove one day to start yesterday $day = Carbon::now()->subDays($i)->format('Y-m-d'); // call for spezific day - if($singleday){ + if ($singleday) { $dback = 1; $day = $singleday; } @@ -102,13 +85,14 @@ class Events ->where('day', $day)->get(); foreach ($ss_days as $ss_day) { - + $sofa_score_categorie_id = $ss_day->tournament->sofa_score_categorie_id; + $tournament_id = $ss_day->tournament_id; // $url = Nuh::$options['base_url'] . "api/v1/category/$sofa_score_categorie_id/scheduled-events/$day"; - $url = Nuh::$options['base_url'] . "api/v1/unique-tournament/$tournament_id/scheduled-events/$day"; + $url = Nuh::$options['base_url']."api/v1/unique-tournament/$tournament_id/scheduled-events/$day"; $rand = rand(500000, 1000000); if ($debug) { @@ -120,13 +104,13 @@ class Events Nuh::$options['s'] = 0; - Nuh::$options['r'] = 0; + Nuh::$options['r'] = 0; foreach ($data['events'] as $event) { - Notice::note($event['season']['name'].' '. $ss_day->day, 'bb'); + Notice::note($event['season']['name'].' '.$ss_day->day, 'bb'); - $folder = app_path() . self::$storage_path . $ss_day->day . '/' . $event['tournament']['slug'] . '/' . $event['slug']; + $folder = app_path().self::$storage_path.$ss_day->day.'/'.$event['tournament']['slug'].'/'.$event['slug']; File::makeDirectory($folder, 0775, true, true); @@ -134,7 +118,7 @@ class Events * EVENT event *********************************/ - File::put($folder . '/event.json', json_encode($event)); + File::put($folder.'/event.json', json_encode($event)); /********************************* * EVENT statistics @@ -142,7 +126,7 @@ class Events $event_id = $event['id']; - $url = Nuh::$options['base_url'] . "api/v1/event/$event_id/statistics"; + $url = Nuh::$options['base_url']."api/v1/event/$event_id/statistics"; $rand = rand(500000, 1000000); if ($debug) { @@ -152,7 +136,7 @@ class Events $data = CurlSofa::load($url); - File::put($folder . '/statistics.json', json_encode($data)); + File::put($folder.'/statistics.json', json_encode($data)); /********************************* * EVENT lineups @@ -160,7 +144,7 @@ class Events $event_id = $event['id']; - $url = Nuh::$options['base_url'] . "api/v1/event/$event_id/lineups"; + $url = Nuh::$options['base_url']."api/v1/event/$event_id/lineups"; $rand = rand(500000, 1000000); if ($debug) { @@ -170,8 +154,7 @@ class Events $data = CurlSofa::load($url); - File::put($folder . '/lineups.json', json_encode($data)); - + File::put($folder.'/lineups.json', json_encode($data)); /********************************* * EVENT lineups @@ -179,7 +162,7 @@ class Events $event_id = $event['id']; - $url = Nuh::$options['base_url'] . "api/v1/event/$event_id/odds/1/all"; + $url = Nuh::$options['base_url']."api/v1/event/$event_id/odds/1/all"; $rand = rand(500000, 1000000); if ($debug) { @@ -189,7 +172,7 @@ class Events $data = CurlSofa::load($url); - File::put($folder . '/odds.json', json_encode($data)); + File::put($folder.'/odds.json', json_encode($data)); } } } diff --git a/app/Console/Commands/Grapper/Sofascore/EventsDatabase.php b/app/Console/Commands/Grapper/Sofascore/EventsDatabase.php new file mode 100644 index 00000000..07e53c37 --- /dev/null +++ b/app/Console/Commands/Grapper/Sofascore/EventsDatabase.php @@ -0,0 +1,137 @@ +where('enabled', 1)->pluck('day')->toArray(); + $tornaments = SofaScoreTournament::where('sport_id', $sport_id)->where('enabled', 1)->get(); + + if (! $days) { + Notice::note('No days active in DB', 'r', 1); + } + if (! $tornaments) { + Notice::note('No tornaments active in DB', 'r', 1); + } + + if ($print) { + dd($days, $tornaments); + } + + foreach ($days as $day) { + + if ($debug) { + Notice::note($day, 'b'); + } + + foreach ($tornaments as $tournament) { + + if ($debug) { + Notice::note($tournament->name, 'b'); + } + + $url = Nuh::$options['base_url']."api/v1/unique-tournament/$tournament->tournament_id/scheduled-events/$day"; + + $rand = rand(500000, 1000000); + + if ($debug) { + Notice::note("Sleep $rand msec", 'y'); + } + + usleep($rand); + + $data = CurlSofa::load($url); + + Nuh::$options['s'] = 0; + + Nuh::$options['r'] = 0; + + if (isset($data['events'])) { + + foreach ($data['events'] as $event) { + + Notice::note($event['season']['name'].' '.$day, 'bb'); + + $folder = app_path().self::$storage_path.$day.'/'.$event['tournament']['slug'].'/'.$event['slug']; + + File::makeDirectory($folder, 0775, true, true); + + /********************************* + * EVENT event + *********************************/ + + File::put($folder.'/event.json', json_encode($event)); + + /********************************* + * EVENT statistics + *********************************/ + + $event_id = $event['id']; + + $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 + *********************************/ + + $event_id = $event['id']; + + $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)); + } + } + } + } + } +} diff --git a/app/Console/Commands/Grapper/Sofascore/Special.php b/app/Console/Commands/Grapper/Sofascore/Special.php index a1137ebd..517862f3 100644 --- a/app/Console/Commands/Grapper/Sofascore/Special.php +++ b/app/Console/Commands/Grapper/Sofascore/Special.php @@ -11,8 +11,8 @@ 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/'; @@ -21,7 +21,7 @@ class Special { $debug = Nuh::$options['d'] ?? 0; - $url = Nuh::$options['base_url'] . "/api/v1/world-cup/meet-the-team"; + $url = Nuh::$options['base_url'].'/api/v1/world-cup/meet-the-team'; $rand = rand(500000, 1000000); if ($debug) { @@ -38,7 +38,7 @@ class Special $teams[] = [ 'id' => $team['team']['id'], 'slug' => $team['team']['slug'], - 'name' => $team['team']['name'] + 'name' => $team['team']['name'], ]; } } @@ -47,9 +47,9 @@ class Special Nuh::$options['s'] = 0; - Nuh::$options['r'] = 0; + Nuh::$options['r'] = 0; - $url = 'https://www.sofascore.com/api/v1/team/' . $team['id'] . '/events/last/0'; + $url = 'https://www.sofascore.com/api/v1/team/'.$team['id'].'/events/last/0'; $data = CurlSofa::load($url); @@ -66,7 +66,7 @@ class Special $starttime = Carbon::createFromTimestamp($event['startTimestamp'])->format('Y-m-d'); - $folder = app_path() . self::$storage_path . $starttime . '/' . $event['tournament']['slug'] . '/' . $event['slug']; + $folder = app_path().self::$storage_path.$starttime.'/'.$event['tournament']['slug'].'/'.$event['slug']; File::makeDirectory($folder, 0775, true, true); @@ -74,13 +74,13 @@ class Special * EVENT event basic *********************************/ - File::put($folder . '/event.json', json_encode($event)); + File::put($folder.'/event.json', json_encode($event)); /********************************* * EVENT statistics *********************************/ - $url = Nuh::$options['base_url'] . "api/v1/event/$event_id/statistics"; + $url = Nuh::$options['base_url']."api/v1/event/$event_id/statistics"; $rand = rand(500000, 1000000); if ($debug) { @@ -90,13 +90,13 @@ class Special $data = CurlSofa::load($url); - File::put($folder . '/statistics.json', json_encode($data)); + File::put($folder.'/statistics.json', json_encode($data)); /********************************* * EVENT lineups *********************************/ - $url = Nuh::$options['base_url'] . "api/v1/event/$event_id/lineups"; + $url = Nuh::$options['base_url']."api/v1/event/$event_id/lineups"; $rand = rand(500000, 1000000); if ($debug) { @@ -106,14 +106,14 @@ class Special $data = CurlSofa::load($url); - File::put($folder . '/lineups.json', json_encode($data)); + 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"; + $url = Nuh::$options['base_url']."api/v1/event/$event_id/odds/1/all"; $rand = rand(500000, 1000000); if ($debug) { @@ -123,7 +123,7 @@ class Special $data = CurlSofa::load($url); - File::put($folder . '/odds.json', json_encode($data)); + File::put($folder.'/odds.json', json_encode($data)); } } } diff --git a/app/Filament/Clusters/Grapper/Resources/Supervisors/Tables/SupervisorsTable.php b/app/Filament/Clusters/Grapper/Resources/Supervisors/Tables/SupervisorsTable.php index 313fb21f..a6596724 100644 --- a/app/Filament/Clusters/Grapper/Resources/Supervisors/Tables/SupervisorsTable.php +++ b/app/Filament/Clusters/Grapper/Resources/Supervisors/Tables/SupervisorsTable.php @@ -13,7 +13,6 @@ use Filament\Actions\DeleteBulkAction; use Filament\Actions\EditAction; use Filament\Forms\Components\TextInput; use Filament\Support\Enums\FontWeight; -use Filament\Support\Enums\Size; use Filament\Support\Enums\TextSize; use Filament\Tables\Columns\Layout\Split; use Filament\Tables\Columns\Layout\Stack; @@ -42,7 +41,7 @@ class SupervisorsTable ->weight(FontWeight::Black) ->size(TextSize::Large), TextColumn::make('provider.name') - ->color(fn($record): string => match ($record->provider_id) { + ->color(fn ($record): string => match ($record->provider_id) { 1 => 'danger', 8 => 'danger', 2 => 'success', @@ -107,7 +106,8 @@ class SupervisorsTable case 12: return [ 'TOURNAMENTS' => 'TOURNAMENTS', - 'EVENTS' => 'EVENTS', + 'EVENTS' => 'EVENTS Comandline', + 'EVENTSDB' => 'EVENTS Database', 'SPECIAL' => 'SPECIAL', ]; default: @@ -118,7 +118,7 @@ class SupervisorsTable ->hidden(function (ListSupervisors $livewire) { return in_array($livewire->tableFilters['provider_id']['value'], [11]); }) - ->options(fn() => Sport::where('is_active', 1)->pluck('name', 'id')) + ->options(fn () => Sport::where('is_active', 1)->pluck('name', 'id')) ->placeholder('All'), SelectColumn::make('txodds_market_id') ->visible(function (ListSupervisors $livewire) { @@ -153,7 +153,7 @@ class SupervisorsTable TextColumn::make('lastcall') ->prefix('Lastcall: ') ->badge() - ->color(fn($state): string => ($state > 0 && $state > time() - 300) ? 'success' : 'danger') + ->color(fn ($state): string => ($state > 0 && $state > time() - 300) ? 'success' : 'danger') ->dateTime() ->visible(function (ListSupervisors $livewire) { return $livewire->tableFilters['provider_id']['value'] == 8; diff --git a/app/Filament/Clusters/StaticData/Resources/SofaScoreDays/Tables/SofaScoreDaysTable.php b/app/Filament/Clusters/StaticData/Resources/SofaScoreDays/Tables/SofaScoreDaysTable.php index dea23abe..004b6f95 100644 --- a/app/Filament/Clusters/StaticData/Resources/SofaScoreDays/Tables/SofaScoreDaysTable.php +++ b/app/Filament/Clusters/StaticData/Resources/SofaScoreDays/Tables/SofaScoreDaysTable.php @@ -5,12 +5,8 @@ namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Tables; use App\Models\SofaScoreDay; use App\Models\Sport; use Filament\Actions\Action; -use Filament\Actions\BulkActionGroup; -use Filament\Actions\DeleteBulkAction; -use Filament\Actions\EditAction; use Filament\Forms\Components\Select; use Filament\Forms\Components\Toggle; -use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\ToggleColumn; use Filament\Tables\Enums\FiltersLayout; @@ -26,16 +22,53 @@ class SofaScoreDaysTable { return $table ->description('For days checked events active in tournaments will be grapped.') - ->headerActions([ - Action::make('reset')->icon('phosphor-power')->action(fn() => SofaScoreDay::query()->update(['football' => 0])), + ->headerActions([ + Action::make('generate')->icon('phosphor-calendar') + ->schema([ + Select::make('sport_id') + ->options(Sport::where('is_active', 1) + ->pluck('name', 'id')) + ->required(), + Select::make('year') + ->options(self::years()) + ->required(), + Select::make('month') + ->options(self::month()) + ->required(), + ]) + ->action(function (array $data, $table): void { + $sport_id = $data['sport_id']; + $date = Carbon::createFromDate($data['year'], $data['month'], 1)->startOfMonth(); + $daysCount = $date->daysInMonth; + + $allDates = []; + for ($i = 1; $i <= $daysCount; $i++) { + $allDates[] = $date->copy()->day($i)->format('Y-m-d'); + } + foreach ($allDates as $day) { + SofaScoreDay::updateOrCreate(['day' => $day, 'sport_id' => $sport_id]); + } + }), + Action::make('reset') + ->icon('phosphor-power') + ->schema([ + Select::make('sport_id') + ->options(Sport::where('is_active', 1) + ->pluck('name', 'id')) + ->required(), + ]) + ->action(function (array $data): void { + $sport_id = $data['sport_id']; + SofaScoreDay::where('sport_id', $sport_id)->update(['enabled' => 0]); + }), ]) ->columns([ - TextColumn::make('day')->sortable(), TextColumn::make('sport.name'), + TextColumn::make('day')->sortable(), ToggleColumn::make('enabled'), ]) ->filters([ - Filter::make('day') + Filter::make('filter') ->columns(4)->columnSpan(4) ->schema([ Select::make('sport_id') @@ -50,13 +83,13 @@ class SofaScoreDaysTable ->query(function (Builder $query, array $data): Builder { return $query->when( $data['year'], - fn(Builder $query, $year): Builder => $query->whereYear('day', $year), + fn (Builder $query, $year): Builder => $query->whereYear('day', $year), )->when( $data['month'], - fn(Builder $query, $month): Builder => $query->whereMonth('day', $month), + fn (Builder $query, $month): Builder => $query->whereMonth('day', $month), )->when( $data['enabled'], - fn(Builder $query, $enabled): Builder => $query->where('enabled', $enabled), + fn (Builder $query, $enabled): Builder => $query->where('enabled', $enabled), ); })->indicateUsing(function (array $data): array { $indicators = []; @@ -66,31 +99,29 @@ class SofaScoreDaysTable if ($data['month'] ?? null) { $indicators[] = Indicator::make('Month: '.$data['month']); } - return $indicators; - }), + + return $indicators; + }), ], layout: FiltersLayout::AboveContent) - ->deferFilters(false) - ->recordActions([ - EditAction::make(), - ]) - ->toolbarActions([ - BulkActionGroup::make([ - // DeleteBulkAction::make(), - ]), - ]); + ->persistFiltersInSession() + ->deferFilters(false); } - public static function years() { - $years = range(date('Y'), date('Y')-10); + public static function years() + { + $years = range(date('Y'), date('Y') - 10); + return array_combine($years, $years); } - public static function month() { + public static function month() + { $months = []; for ($m = 1; $m <= 12; $m++) { $date = Carbon::create(null, $m, 1); $months[$date->format('m')] = $date->format('F'); } + return $months; } } diff --git a/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php b/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php index 77ee5867..5ebe50ea 100644 --- a/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php +++ b/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php @@ -33,121 +33,121 @@ class SofaScoreTournamentsTable ->icon('phosphor-power') ->requiresConfirmation() ->modalDescription('This will disable all leagues for soccer') - ->action(fn() => SofaScoreTournament::where('sport_id', 1)->update(['enabled' => 0]) - ), + ->action(fn () => SofaScoreTournament::where('sport_id', 1)->update(['enabled' => 0]) + ), Action::make('ice-hockey') ->icon('phosphor-power') ->requiresConfirmation() ->modalDescription('This will disable all leagues for ice hockey') - ->action(fn() => SofaScoreTournament::where('sport_id', 2)->update(['enabled' => 0]) - ), + ->action(fn () => SofaScoreTournament::where('sport_id', 2)->update(['enabled' => 0]) + ), Action::make('basketball') ->icon('phosphor-power') ->requiresConfirmation() ->modalDescription('This will disable all leagues for basketball') - ->action(fn() => SofaScoreTournament::where('sport_id', 3)->update(['enabled' => 0]) - ), + ->action(fn () => SofaScoreTournament::where('sport_id', 3)->update(['enabled' => 0]) + ), Action::make('tennis') ->icon('phosphor-power') ->requiresConfirmation() ->modalDescription('This will disable all leagues for tennis') - ->action(fn() => SofaScoreTournament::where('sport_id', 5)->update(['enabled' => 0]) - ), + ->action(fn () => SofaScoreTournament::where('sport_id', 5)->update(['enabled' => 0]) + ), ]) ->poll() ->columns([ - IconColumn::make('sport.icon') - ->label('') - ->grow(false) - ->width(30) - ->color(fn($record) => $record->sport->color) - ->icon(fn($record) => $record->sport->icon) - ->size(IconSize::Medium) - ->tooltip(fn($record) => $record->id) - ->visibleFrom('lg'), - TextColumn::make('tournament_id')->sortable(), - TextColumn::make('sport.name'), - TextColumn::make('sofascore_category.name') - ->icon(fn($record) => $record->sofascore_category->country->icon), - TextColumn::make('name')->searchable()->sortable(), - ToggleColumn::make('enabled'), + IconColumn::make('sport.icon') + ->label('') + ->grow(false) + ->width(30) + ->color(fn ($record) => $record->sport->color) + ->icon(fn ($record) => $record->sport->icon) + ->size(IconSize::Medium) + ->tooltip(fn ($record) => $record->id) + ->visibleFrom('lg'), + TextColumn::make('tournament_id')->sortable()->searchable(), + TextColumn::make('sport.name'), + TextColumn::make('sofascore_category.name') + ->icon(fn ($record) => $record->sofascore_category->country->icon), + TextColumn::make('name')->searchable()->sortable(), + ToggleColumn::make('enabled'), ]) ->filters([ - Filter::make('filters') - ->columns(3)->columnSpan(3) - ->schema([ - Select::make('sport_id') - ->default(1) - ->selectablePlaceholder(false) - ->label('Sport') - ->options(Sport::where('is_active', 1)->pluck('name', 'id')) - ->afterStateUpdated(function (callable $set) { - $set('sofa_score_categorie_id', null); - }) - ->live(), - Select::make('sofa_score_categorie_id') - ->searchable() - ->multiple() - ->label('Categorie') - ->options(function (Get $get) { - $res = SofaScoreTournament::where('sport_id', $get('sport_id')) - ->groupBy('sofa_score_categorie_id') - ->pluck('sofa_score_categorie_id') - ->toArray(); + Filter::make('filters') + ->columns(3)->columnSpan(3) + ->schema([ + Select::make('sport_id') + ->default(1) + ->selectablePlaceholder(false) + ->label('Sport') + ->options(Sport::where('is_active', 1)->pluck('name', 'id')) + ->afterStateUpdated(function (callable $set) { + $set('sofa_score_categorie_id', null); + }) + ->live(), + Select::make('sofa_score_categorie_id') + ->searchable() + ->multiple() + ->label('Categorie') + ->options(function (Get $get) { + $res = SofaScoreTournament::where('sport_id', $get('sport_id')) + ->groupBy('sofa_score_categorie_id') + ->pluck('sofa_score_categorie_id') + ->toArray(); - return SofaScoreCategorie::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id'); - }) - ->live(), - DatePicker::make('day')->live(), - ]) - ->query(function (Builder $query, array $data): Builder { - return $query->when( - $data['sport_id'], - fn(Builder $query, $sport_id) => $query->where('sport_id', $sport_id) - )->when( - $data['sofa_score_categorie_id'], - function (Builder $query, $sofa_score_categorie_id) { - if (is_array($sofa_score_categorie_id)) { - $query->whereIn('sofa_score_categorie_id', $sofa_score_categorie_id); - } else { - $query->where('sofa_score_categorie_id', $sofa_score_categorie_id); + return SofaScoreCategorie::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id'); + }) + ->live(), + DatePicker::make('day')->live(), + ]) + ->query(function (Builder $query, array $data): Builder { + return $query->when( + $data['sport_id'], + fn (Builder $query, $sport_id) => $query->where('sport_id', $sport_id) + )->when( + $data['sofa_score_categorie_id'], + function (Builder $query, $sofa_score_categorie_id) { + if (is_array($sofa_score_categorie_id)) { + $query->whereIn('sofa_score_categorie_id', $sofa_score_categorie_id); + } else { + $query->where('sofa_score_categorie_id', $sofa_score_categorie_id); + } } - } - )->when( - $data['day'], - function (Builder $query, $day) { - $res = SofaScoreDayTournament::where('day', $day)->pluck('tournament_id')->toArray(); - $query->whereIn('tournament_id', $res); - } - ); - }), - TernaryFilter::make('enabled')->placeholder('All'), + )->when( + $data['day'], + function (Builder $query, $day) { + $res = SofaScoreDayTournament::where('day', $day)->pluck('tournament_id')->toArray(); + $query->whereIn('tournament_id', $res); + } + ); + }), + TernaryFilter::make('enabled')->placeholder('All'), ], layout: FiltersLayout::AboveContent) ->deferFilters(false) ->toolbarActions([ BulkActionGroup::make([ - BulkAction::make('Enable') - ->icon('phosphor-toggle-right-fill') - ->color('primary') - ->action(function (Collection $records): void { - foreach ($records as $record) { - SofaScoreTournament::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) { - SofaScoreTournament::where('id', '=', $record->id) - ->update( - ['enabled' => 0] - ); - } - }), + BulkAction::make('Enable') + ->icon('phosphor-toggle-right-fill') + ->color('primary') + ->action(function (Collection $records): void { + foreach ($records as $record) { + SofaScoreTournament::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) { + SofaScoreTournament::where('id', '=', $record->id) + ->update( + ['enabled' => 0] + ); + } + }), ]), ]); } diff --git a/composer.lock b/composer.lock index fd80130e..9fa1044d 100644 --- a/composer.lock +++ b/composer.lock @@ -4457,24 +4457,24 @@ }, { "name": "mongodb/mongodb", - "version": "2.2.0", + "version": "2.3.0", "source": { "type": "git", - "url": "https://github.com/mongodb/mongo-php-library.git", - "reference": "bbb13f969e37e047fd822527543df55fdc1c9298" + "url": "https://github.com/mongodb/mongo-php-library", + "reference": "12e56461166d915e3dd8e4969ad0940ed5207d88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/bbb13f969e37e047fd822527543df55fdc1c9298", - "reference": "bbb13f969e37e047fd822527543df55fdc1c9298", + "url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/12e56461166d915e3dd8e4969ad0940ed5207d88", + "reference": "12e56461166d915e3dd8e4969ad0940ed5207d88", "shasum": "" }, "require": { "composer-runtime-api": "^2.0", - "ext-mongodb": "^2.2", + "ext-mongodb": "^2.3", "php": "^8.1", "psr/log": "^1.1.4|^2|^3", - "symfony/polyfill-php85": "^1.32" + "symfony/polyfill-php85": "^1.33" }, "replace": { "mongodb/builder": "*" @@ -4526,11 +4526,7 @@ "mongodb", "persistence" ], - "support": { - "issues": "https://github.com/mongodb/mongo-php-library/issues", - "source": "https://github.com/mongodb/mongo-php-library/tree/2.2.0" - }, - "time": "2026-02-11T11:39:56+00:00" + "time": "2026-04-28T12:50:06+00:00" }, { "name": "monolog/monolog", @@ -8027,6 +8023,90 @@ ], "time": "2026-04-10T16:19:22+00:00" }, + { + "name": "symfony/polyfill-iconv", + "version": "v1.37.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-iconv.git", + "reference": "2c5729fd241b4b22f6e4b436bc3354a4f262df57" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/2c5729fd241b4b22f6e4b436bc3354a4f262df57", + "reference": "2c5729fd241b4b22f6e4b436bc3354a4f262df57", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-iconv": "*" + }, + "suggest": { + "ext-iconv": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Iconv\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Iconv extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "iconv", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-iconv/tree/v1.37.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2026-04-10T16:19:22+00:00" + }, { "name": "symfony/polyfill-intl-grapheme", "version": "v1.38.1",