fix update player

This commit is contained in:
salam committed 2026-09-11 10:36:16 +02:00
1 parent e3f1e8a8d9
commit f028a8b2a8
16 files changed
+605 -224

No files matched your search

+10 -7
View File
@@ -2,13 +2,15 @@
namespace App\Filament\Imports\Helper;
use App\Actions\PlayerPerSeason;
use App\Models\StatistikoPlayer;
use App\Traits\UpdatePlayerSeasonHelper;
use Illuminate\Support\LazyCollection;
use Spatie\SimpleExcel\SimpleExcelReader;
class ImportPlayer
{
use UpdatePlayerSeasonHelper;
public static function run(string $filePath): void
{
$fieldnames = [
@@ -78,10 +80,10 @@ class ImportPlayer
'penaltyshoutout_missed',
'player_position',
'playerrating_value',
'tm_player_id'
'tm_player_id',
];
SimpleExcelReader::create(storage_path('app/public/' . $filePath))
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
->getRows()
->chunk(1000)
->each(function (LazyCollection $chunk) use ($fieldnames) {
@@ -95,12 +97,13 @@ class ImportPlayer
$update_array = [];
foreach ($fieldnames as $key => $name) {
if ($key == 1)
if ($key == 1) {
$match_id = (int) $row[$key];
else if ($key == 2)
} elseif ($key == 2) {
$ss_player_id = (int) $row[$key];
else
} else {
$update_array[$name] = $row[$key];
}
}
StatistikoPlayer::updateOrCreate(
@@ -114,6 +117,6 @@ class ImportPlayer
});
/**update statistic player tabel */
PlayerPerSeason::run();
UpdatePlayerSeasonHelper::update(1000000);
}
}