statistic on separate page wip
This commit is contained in:
1 parent
ad36ba555f
commit
422681df01
34 files changed
+660
-734
No files matched your search
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports\Helper;
|
||||
|
||||
use App\Models\StatisticFixtures;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\LazyCollection;
|
||||
use Spatie\SimpleExcel\SimpleExcelReader;
|
||||
|
||||
class ImportFixtures
|
||||
{
|
||||
public static function run(string $filePath, $sport_id): void
|
||||
{
|
||||
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||
->getRows()
|
||||
->chunk(200)
|
||||
->each(function (LazyCollection $chunk) use ($sport_id) {
|
||||
|
||||
foreach ($chunk as $row) {
|
||||
|
||||
$row = array_values($row);
|
||||
|
||||
/*
|
||||
0 => 87
|
||||
1 => 3614
|
||||
2 => 1491
|
||||
3 => DateTimeImmutable @1777334400 {#2722 ▶}
|
||||
4 => 0.90433699503783
|
||||
5 => 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(),
|
||||
],
|
||||
['exp_home' => (float) $row[4], 'exp_away' => (float) $row[5]]
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user