add sportid in excel to ImportFixtures
This commit is contained in:
1 parent
d71635703f
commit
06013ac857
3 files changed
+239
-243
No files matched your search
@@ -9,35 +9,36 @@ use Spatie\SimpleExcel\SimpleExcelReader;
|
||||
|
||||
class ImportFixtures
|
||||
{
|
||||
public static function run(string $filePath, $sport_id): void
|
||||
public static function run(string $filePath): void
|
||||
{
|
||||
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||
->getRows()
|
||||
->chunk(200)
|
||||
->each(function (LazyCollection $chunk) use ($sport_id) {
|
||||
->each(function (LazyCollection $chunk) {
|
||||
|
||||
foreach ($chunk as $row) {
|
||||
|
||||
$row = array_values($row);
|
||||
|
||||
/*
|
||||
0 => 87
|
||||
1 => 3614
|
||||
2 => 1491
|
||||
3 => DateTimeImmutable @1777334400 {#2722 ▶}
|
||||
4 => 0.90433699503783
|
||||
5 => 1.035168989838
|
||||
0 => 1
|
||||
1 => 87
|
||||
2 => 3614
|
||||
3 => 1491
|
||||
4 => DateTimeImmutable @1777334400 {#2722 ▶}
|
||||
5 => 0.90433699503783
|
||||
6 => 1.035168989838
|
||||
*/
|
||||
|
||||
StatisticFixtures::updateOrCreate(
|
||||
[
|
||||
'sport_id' => (int) $sport_id,
|
||||
'league_id' => (int) $row[0],
|
||||
'home_id' => (int) $row[1],
|
||||
'away_id' => (int) $row[2],
|
||||
'starttime' => Carbon::parse($row[3])->toDateString(),
|
||||
'sport_id' => (int) $row[0],
|
||||
'league_id' => (int) $row[1],
|
||||
'home_id' => (int) $row[2],
|
||||
'away_id' => (int) $row[3],
|
||||
'starttime' => Carbon::parse($row[4])->toDateString(),
|
||||
],
|
||||
['exp_home' => (float) $row[4], 'exp_away' => (float) $row[5]]
|
||||
['exp_home' => (float) $row[5], 'exp_away' => (float) $row[6]]
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user