diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoImports/Schemas/StatistikoImportForm.php b/app/Filament/Clusters/StaticData/Resources/StatistikoImports/Schemas/StatistikoImportForm.php index c8533796..5cfc7ecc 100644 --- a/app/Filament/Clusters/StaticData/Resources/StatistikoImports/Schemas/StatistikoImportForm.php +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoImports/Schemas/StatistikoImportForm.php @@ -21,6 +21,7 @@ class StatistikoImportForm 'player' => 'Player History', 'fixtures' => 'Fixtures Upcoming', 'events' => 'Events History', + 'teams_tornaments' => 'Teams in Tornaments', ]), FileUpload::make('file_name') diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoImports/Tables/StatistikoImportsTable.php b/app/Filament/Clusters/StaticData/Resources/StatistikoImports/Tables/StatistikoImportsTable.php index 8d7c4a03..897d99e3 100644 --- a/app/Filament/Clusters/StaticData/Resources/StatistikoImports/Tables/StatistikoImportsTable.php +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoImports/Tables/StatistikoImportsTable.php @@ -32,6 +32,7 @@ class StatistikoImportsTable 'player' => 'Player History', 'fixtures' => 'Fixtures Upcoming', 'events' => 'Events History', + 'teams_tornaments' => 'Teams in Tornaments', ]), TextColumn::make('file_name_original') ->sortable() @@ -55,6 +56,7 @@ class StatistikoImportsTable 'events' => 'Events', 'fixtures' => 'Fixtures', 'player' => 'Player', + 'teams_tornaments' => 'Teams in Tornaments', ]), ], layout: FiltersLayout::AboveContent) ->filtersFormColumns(6) @@ -67,7 +69,7 @@ class StatistikoImportsTable ->color('success') ->tooltip('Update or create') ->icon('phosphor-database') - ->action(fn($record) => StatistikoImporter::run($record)) + ->action(fn ($record) => StatistikoImporter::run($record)) ->successNotification( Notification::make() ->info() diff --git a/app/Filament/Imports/Helper/ImportTeamsTournaments.php b/app/Filament/Imports/Helper/ImportTeamsTournaments.php new file mode 100644 index 00000000..e692a9b1 --- /dev/null +++ b/app/Filament/Imports/Helper/ImportTeamsTournaments.php @@ -0,0 +1,45 @@ +update(['in_update' => 0]); + + SimpleExcelReader::create(storage_path('app/public/'.$filePath)) + ->getRows() + ->chunk(100) + ->each(function (LazyCollection $chunk) { + + foreach ($chunk as $row) { + + $row = array_values($row); + + self::$active_tournament[] = $row[0]; + + dd($row); + SofaScoreRosaTournament::updateOrCreate( + [ + 'ss_tournament_id' => (int) $row[0], + ], + [ + 'ss_team_id' => (int) $row[1], + 'in_update' => 1, + ] + ); + } + }); + + $tournaments = array_unique(self::$active_tournament); + + SofaScoreRosaTournament::where('in_update', 0)->whereIn('torunament_id', $tournaments)->delete(); + } +} diff --git a/app/Filament/Imports/StatistikoImporter.php b/app/Filament/Imports/StatistikoImporter.php index f26e4510..a2870242 100644 --- a/app/Filament/Imports/StatistikoImporter.php +++ b/app/Filament/Imports/StatistikoImporter.php @@ -7,6 +7,7 @@ use App\Filament\Imports\Helper\ImportDetails; use App\Filament\Imports\Helper\ImportEvents; use App\Filament\Imports\Helper\ImportFixtures; use App\Filament\Imports\Helper\ImportPlayer; +use App\Filament\Imports\Helper\ImportTeamsTournaments; use App\Models\StatistikoImport; class StatistikoImporter @@ -44,6 +45,10 @@ class StatistikoImporter case 'player': ImportPlayer::run($filePath); break; + case 'teams_tornaments': + ImportTeamsTournaments::run($filePath); + break; + } StatistikoImport::query()->where('id', $record->id)->update(['has_run' => 1]); diff --git a/database/migrations/2026_07_29_132745_create_sofa_score_rosa_tournaments_table.php b/database/migrations/2026_07_29_132745_create_sofa_score_rosa_tournaments_table.php index 2f36a577..02a6101d 100644 --- a/database/migrations/2026_07_29_132745_create_sofa_score_rosa_tournaments_table.php +++ b/database/migrations/2026_07_29_132745_create_sofa_score_rosa_tournaments_table.php @@ -17,6 +17,7 @@ return new class extends Migration $table->integer('ss_tournament_id')->default(0)->nullable()->index(); $table->boolean('disabled')->default(false); $table->boolean('grapped')->default(false); + $table->boolean('in_update')->default(false); $table->timestamps(); }); }