check double upload player event wip
This commit is contained in:
1 parent
9954f47139
commit
fd7b8fadad
7 files changed
+86
-91
No files matched your search
@@ -9,47 +9,26 @@ use Spatie\SimpleExcel\SimpleExcelReader;
|
||||
|
||||
class ImportDetails
|
||||
{
|
||||
public static function run(string $filePath, string $importmode): void
|
||||
public static function run(string $filePath): void
|
||||
{
|
||||
$now = now()->format('Y-m-d H:i:s');
|
||||
|
||||
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||
SimpleExcelReader::create(storage_path('app/public/' . $filePath))
|
||||
->getRows()
|
||||
->chunk(1000)
|
||||
->each(function (LazyCollection $chunk) use ($now, $importmode) {
|
||||
->each(function (LazyCollection $chunk) use ($now) {
|
||||
|
||||
foreach ($chunk as $row) {
|
||||
|
||||
$row = array_values($row);
|
||||
|
||||
if ($importmode == 'update') {
|
||||
StatistikoDetail::where('tm_player_id', $row[0])
|
||||
->update(
|
||||
[
|
||||
'name' => $row[1],
|
||||
'birthdate' => Carbon::parse($row[2])->toDateString(),
|
||||
'height' => $row[3],
|
||||
'nationality' => $row[4],
|
||||
'position' => $row[5],
|
||||
'sport_radar_id' => $row[6],
|
||||
'id_squadra_tm' => $row[7],
|
||||
'full_name' => $row[8],
|
||||
'no_specialities' => $row[9],
|
||||
'txodds_id' => $row[10],
|
||||
'national_team_id' => $row[11],
|
||||
'last_update' => Carbon::parse($row[12])->toDateString(),
|
||||
'league_code' => $row[13],
|
||||
'team_code' => $row[14],
|
||||
'team_name' => $row[15],
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
['upsert' => true],
|
||||
);
|
||||
} else {
|
||||
StatistikoDetail::insert(
|
||||
if ($row[1] != '') {
|
||||
|
||||
StatistikoDetail::updateOrCreate(
|
||||
[
|
||||
'tm_player_id' => (int) $row[0],
|
||||
],
|
||||
[
|
||||
'tm_player_id', $row[0],
|
||||
'name' => $row[1],
|
||||
'birthdate' => Carbon::parse($row[2])->toDateString(),
|
||||
'height' => $row[3],
|
||||
|
||||
Reference in new issue
Block a user