This commit is contained in:
salam committed 2026-10-14 13:41:31 +02:00
1 parent b89410c8f1
commit e09e42ab41
2 files changed
+9 -3

No files matched your search

@@ -9,10 +9,13 @@ use Spatie\SimpleExcel\SimpleExcelReader;
class ImportDetails class ImportDetails
{ {
public static $teams = [];
public static function run(string $filePath): void public static function run(string $filePath): void
{ {
// StatistikoDetail::query()->update(['last_import' => 'no']); StatistikoDetail::query()->update(['last_import' => 'no']);
self::$teams = [];
SimpleExcelReader::create(storage_path('app/public/'.$filePath)) SimpleExcelReader::create(storage_path('app/public/'.$filePath))
->getRows() ->getRows()
->chunk(1000) ->chunk(1000)
@@ -20,6 +23,7 @@ class ImportDetails
$collection = []; $collection = [];
foreach ($chunk as $row) { foreach ($chunk as $row) {
self::$teams[] = $row['ss_team_id'];
if ($row['player_name'] != '') { if ($row['player_name'] != '') {
$row['is_active'] = 1; $row['is_active'] = 1;
$row['last_import'] = 'yes'; $row['last_import'] = 'yes';
@@ -50,6 +54,8 @@ class ImportDetails
]); ]);
}); });
// StatistikoDetail::where('last_import', 'no')->update(['is_active' => 0, 'ss_team_id' => 0]); self::$teams = array_unique(self::$teams);
StatistikoDetail::where('last_import', 'no')->whereIn('ss_team_id', self::$teams)->update(['is_active' => 0, 'ss_team_id' => 0]);
} }
} }
@@ -12,7 +12,7 @@ class LoadPlayerAverages
{ {
// dd($team_id); // dd($team_id);
$players = StatistikoDetail::where('ss_team_id', $team_id)->get(); $players = StatistikoDetail::where('ss_team_id', $team_id)->where('is_active', 1)->get();
$player_ids = []; $player_ids = [];
foreach ($players as $player) { foreach ($players as $player) {