Modified events with sport-id and match_id, same for players
This commit is contained in:
1 parent
1c4480b014
commit
9978b0f76f
12 files changed
+205
-152
No files matched your search
@@ -9,45 +9,46 @@ use Spatie\SimpleExcel\SimpleExcelReader;
|
||||
|
||||
class ImportEvents
|
||||
{
|
||||
public static function run(string $filePath, int $sport_id): void
|
||||
public static function run(string $filePath): void
|
||||
{
|
||||
$now = now()->format('Y-m-d H:i:s');
|
||||
|
||||
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||
->getRows()
|
||||
->chunk(1000)
|
||||
->each(function (LazyCollection $chunk) use ($now, $sport_id) {
|
||||
->each(function (LazyCollection $chunk) use ($now) {
|
||||
|
||||
foreach ($chunk as $row) {
|
||||
|
||||
$row = array_values($row);
|
||||
|
||||
StatistikoEvent::where('sport_id', $sport_id)
|
||||
->where('league_id', $row[0])
|
||||
->where('home_id', $row[1])
|
||||
->where('away_id', $row[2])
|
||||
->where('starttime', Carbon::parse($row[3])->toIso8601String())
|
||||
StatistikoEvent::where('match_id', $row[0])
|
||||
->where('sport_id', $row[1])
|
||||
->where('league_id', $row[2])
|
||||
->where('home_id', $row[3])
|
||||
->where('away_id', $row[4])
|
||||
->where('starttime', Carbon::parse($row[5])->toIso8601String())
|
||||
->update(
|
||||
[
|
||||
'season' => $row[4],
|
||||
'gls_h' => $row[5],
|
||||
'gls_a' => $row[6],
|
||||
'crn_h' => $row[7],
|
||||
'crn_a' => $row[8],
|
||||
'fls_h' => $row[9],
|
||||
'fls_a' => $row[10],
|
||||
'ofs_h' => $row[11],
|
||||
'ofs_a' => $row[12],
|
||||
'snt_h' => $row[13],
|
||||
'snt_a' => $row[14],
|
||||
'tsh_h' => $row[15],
|
||||
'tsh_a' => $row[16],
|
||||
'crd_h' => $row[17],
|
||||
'crd_a' => $row[18],
|
||||
'exp_home' => $row[19],
|
||||
'exp_away' => $row[20],
|
||||
'exp_handicap' => $row[21],
|
||||
'exp_total' => $row[22],
|
||||
'season' => $row[6],
|
||||
'gls_h' => $row[7],
|
||||
'gls_a' => $row[8],
|
||||
'crn_h' => $row[9],
|
||||
'crn_a' => $row[10],
|
||||
'fls_h' => $row[11],
|
||||
'fls_a' => $row[12],
|
||||
'ofs_h' => $row[13],
|
||||
'ofs_a' => $row[14],
|
||||
'snt_h' => $row[15],
|
||||
'snt_a' => $row[16],
|
||||
'tsh_h' => $row[17],
|
||||
'tsh_a' => $row[18],
|
||||
'crd_h' => $row[19],
|
||||
'crd_a' => $row[20],
|
||||
'exp_home' => $row[21],
|
||||
'exp_away' => $row[22],
|
||||
'exp_handicap' => $row[23],
|
||||
'exp_total' => $row[24],
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user