This commit is contained in:
salam committed 2026-10-22 16:02:27 +02:00
1 parent d6a13837c5
commit 9cfa60de30
5 files changed
+55 -1

No files matched your search

@@ -0,0 +1,45 @@
<?php
namespace App\Filament\Imports\Helper;
use App\Models\SofaScoreRosaTournament;
use Illuminate\Support\LazyCollection;
use Spatie\SimpleExcel\SimpleExcelReader;
class ImportTeamsTournaments
{
public static $active_tournament = [];
public static function run(string $filePath): void
{
SofaScoreRosaTournament::query()->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();
}
}
@@ -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]);