where('league_id', $this->data['league_id']) ->where('home_id', $this->data['home_id']) ->where('away_id', $this->data['away_id']) ->where('player_id', $this->data['player_id']) ->where('starttime', $this->data['starttime']) ->first(); if ($res) { return UbEvent::find($res->id); } else { return new UbEvent; } } public static function getColumns(): array { return [ ImportColumn::make('league_id')->numeric(), ImportColumn::make('home_id')->numeric(), ImportColumn::make('away_id')->numeric(), ImportColumn::make('player_id')->numeric(), ImportColumn::make('starttime') ->castStateUsing(function ($state) { return Carbon::parse($state); }), ImportColumn::make('home_away') ->castStateUsing(function (string $state): ?string { return (string) trim($state); }), ImportColumn::make('home_ft')->numeric(), ImportColumn::make('away_ft')->numeric(), ImportColumn::make('home_ht')->numeric(), ImportColumn::make('away_ht')->numeric(), ImportColumn::make('goals')->numeric(), ImportColumn::make('assists')->numeric(), ImportColumn::make('tackles')->numeric(), ImportColumn::make('total_passes')->numeric(), ImportColumn::make('passes_done')->numeric(), ImportColumn::make('total_duels')->numeric(), ImportColumn::make('duels_won')->numeric(), ImportColumn::make('total_ground_duels')->numeric(), ImportColumn::make('ground_duels_won')->numeric(), ImportColumn::make('total_aerial_duels')->numeric(), ImportColumn::make('aerial_duels_won')->numeric(), ImportColumn::make('minutes_played')->numeric(), ImportColumn::make('shots_on_target')->numeric(), ImportColumn::make('shots_off_target')->numeric(), ImportColumn::make('shots_blocked')->numeric(), ImportColumn::make('total_dribble')->numeric(), ImportColumn::make('dribble_done')->numeric(), ImportColumn::make('position') ->castStateUsing(function (string $state): ?string { return (string) trim($state); }), ImportColumn::make('rating') ->castStateUsing(function (string $state): ?string { return (string) trim($state); }), ImportColumn::make('bcm')->numeric(), ImportColumn::make('hw')->numeric(), ImportColumn::make('pw')->numeric(), ImportColumn::make('pm')->numeric(), ImportColumn::make('possession_lost')->numeric(), ImportColumn::make('fouls')->numeric(), ImportColumn::make('was_fouled')->numeric(), ImportColumn::make('offsides')->numeric(), ImportColumn::make('date_acquisition') ->castStateUsing(function ($state) { return Carbon::parse($state); }), ]; } public static function getCompletedNotificationBody(Import $import): string { $body = 'Your events import has completed and '.Number::format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.'; if ($failedRowsCount = $import->getFailedRowsCount()) { $body .= ' '.Number::format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.'; } return $body; } }