This commit is contained in:
salam committed 2026-06-10 18:08:34 +02:00
1 parent f7c6b222db
commit d08aea46cd
2 files changed
+102 -56

No files matched your search

+37 -23
View File
@@ -15,7 +15,7 @@ class ImportPlayer
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
->getRows()
->chunk(1000)
->each(function (LazyCollection $chunk) use ($fieldnames, $importmode) {
->each(function (LazyCollection $chunk) use ($fieldnames) {
foreach ($chunk as $row) {
@@ -23,29 +23,43 @@ class ImportPlayer
// print_r($row);
if ($importmode == 'update') {
$update_array = [];
foreach ($fieldnames as $key => $name) {
$offset = (int) $key + 4;
$update_array[$name] = $row[$offset];
}
// dd($update_array);
StatistikoPlayer::where('sport_id', (int) $row[0])
->where('match_id', (int) $row[1])
->where('ss_player_id', (int) $row[2])
->where('tm_player_id', (int) $row[3])
->update($update_array, ['upsert' => true]);
} else {
$insert_array = [];
foreach ($fieldnames as $key => $name) {
$insert_array[$name] = $row[$key];
}
StatistikoPlayer::insert($insert_array);
$update_array = [];
foreach ($fieldnames as $key => $name) {
$offset = (int) $key + 4;
$update_array[$name] = $row[$offset];
}
// dd($update_array);
StatistikoPlayer::where('sport_id', (int) $row[0])
->where('match_id', (int) $row[1])
->where('ss_player_id', (int) $row[2])
->where('tm_player_id', (int) $row[3])
->update($update_array, ['upsert' => true]);
// if ($importmode == 'update') {
// $update_array = [];
// foreach ($fieldnames as $key => $name) {
// $offset = (int) $key + 4;
// $update_array[$name] = $row[$offset];
// }
// // dd($update_array);
// StatistikoPlayer::where('sport_id', (int) $row[0])
// ->where('match_id', (int) $row[1])
// ->where('ss_player_id', (int) $row[2])
// ->where('tm_player_id', (int) $row[3])
// ->update($update_array, ['upsert' => true]);
// } else {
// $insert_array = [];
// foreach ($fieldnames as $key => $name) {
// $insert_array[$name] = $row[$key];
// }
// StatistikoPlayer::insert($insert_array);
// }
}
});
}