wip
This commit is contained in:
1 parent
e46bda0715
commit
433a281999
10 files changed
+285
-274
No files matched your search
+22
-2
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoEvents\Tables;
|
||||
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class StatistikoEventsTable
|
||||
@@ -28,8 +31,25 @@ class StatistikoEventsTable
|
||||
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
SelectFilter::make('sport_id')
|
||||
->default(1)
|
||||
->label('Sport')
|
||||
->preload()
|
||||
->options(Sport::where('is_active', 1)->pluck('name', 'id')),
|
||||
SelectFilter::make('league_id')
|
||||
->relationship('league', 'name')
|
||||
->searchable()
|
||||
->label('League'),
|
||||
SelectFilter::make('home_id')
|
||||
->relationship('home', 'name')
|
||||
->searchable()
|
||||
->label('Home'),
|
||||
SelectFilter::make('away_id')
|
||||
->relationship('away', 'name')
|
||||
->searchable()
|
||||
->label('Away'),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -93,37 +94,35 @@ class StatistikoImporter
|
||||
->chunk(1000)
|
||||
->each(function (LazyCollection $chunk) use ($now) {
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($chunk as $row) {
|
||||
|
||||
$row = array_values($row);
|
||||
|
||||
// check if name exists
|
||||
if (is_string(preg_replace("'\W'", '', $row[1]))) {
|
||||
$data[] = [
|
||||
'player_id' => $row[0],
|
||||
'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],
|
||||
'rigorist' => $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,
|
||||
];
|
||||
}
|
||||
StatistikoPlayer::where('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],
|
||||
'rigorist' => $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],
|
||||
);
|
||||
|
||||
}
|
||||
StatistikoPlayer::upsert($data, 'player_id');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -136,70 +135,42 @@ class StatistikoImporter
|
||||
->chunk(1000)
|
||||
->each(function (LazyCollection $chunk) use ($now) {
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($chunk as $row) {
|
||||
|
||||
// print_r($row);
|
||||
|
||||
$row = array_values($row);
|
||||
|
||||
// dd($row);
|
||||
/***
|
||||
[LEAGUE] => 1
|
||||
[HOME] => 2133
|
||||
[AWAY] => 3024
|
||||
[SS_STARTTIME_VALUE] => DateTimeImmutable Object ( [date] => 2022-08-05 18:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Vienna )
|
||||
[SS_SEASON_VALUE] => 2022/2023
|
||||
[GLS_H] => 0
|
||||
[GLS_A] => 0
|
||||
[CRN_H] => 3
|
||||
[CRN_A] => 6
|
||||
[FLS_H] => 5
|
||||
[FLS_A] => 8
|
||||
[OFS_H] => 0
|
||||
[OFS_A] => 2
|
||||
[SNT_H] => 2
|
||||
[SNT_A] => 1
|
||||
[TSH_H] => 11
|
||||
[TSH_A] => 13
|
||||
[CRD_H] => 1
|
||||
[CRD_A] => 1
|
||||
[EXPGOALSHOME_VALUE] => 1.6350036183338
|
||||
[EXPGOALSAWAY_VALUE] => 0.97303070109903
|
||||
[EXP_HANDICAP] => -0.66197291723478
|
||||
[EXP_TOTAL] => 2.6080343194328
|
||||
*/
|
||||
$data[] = [
|
||||
'sport_id' => 1,
|
||||
'league_id' => $row[0],
|
||||
'home_id' => $row[1],
|
||||
'away_id' => $row[2],
|
||||
'starttime' => Carbon::parse($row[3])->toIso8601String(),
|
||||
'season' => $row[4],
|
||||
'gls_h' => $row[6],
|
||||
'gls_a' => $row[7],
|
||||
'crn_h' => $row[8],
|
||||
'fls_h' => $row[9],
|
||||
'ofs_h' => $row[10],
|
||||
'snt_h' => $row[11],
|
||||
'tsh_h' => $row[12],
|
||||
'crd_h' => $row[13],
|
||||
'crn_a' => $row[14],
|
||||
'fls_a' => $row[15],
|
||||
'ofs_a' => $row[16],
|
||||
'snt_a' => $row[17],
|
||||
'tsh_a' => $row[18],
|
||||
'crd_a' => $row[19],
|
||||
'expgoalshome_value' => $row[20],
|
||||
'expgoalsaway_value' => $row[21],
|
||||
'exp_handicap' => $row[22],
|
||||
'exp_total' => $row[23],
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
StatistikoEvent::where('sport_id', 1)
|
||||
->where('league_id', $row[0])
|
||||
->where('home_id', $row[1])
|
||||
->where('away_id', $row[2])
|
||||
->where('starttime', Carbon::parse($row[3])->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],
|
||||
'expgoalshome_value' => $row[19],
|
||||
'expgoalsaway_value' => $row[20],
|
||||
'exp_handicap' => $row[21],
|
||||
'exp_total' => $row[22],
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
['upsert' => true],
|
||||
);
|
||||
}
|
||||
StatistikoPlayer::upsert($data, 'player_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -23,21 +23,23 @@ class StatistikoEvent extends Model
|
||||
'gls_h',
|
||||
'gls_a',
|
||||
'crn_h',
|
||||
'fls_h',
|
||||
'ofs_h',
|
||||
'snt_h',
|
||||
'tsh_h',
|
||||
'crd_h',
|
||||
'crn_a',
|
||||
'fls_h',
|
||||
'fls_a',
|
||||
'ofs_h',
|
||||
'ofs_a',
|
||||
'snt_h',
|
||||
'snt_a',
|
||||
'tsh_h',
|
||||
'tsh_a',
|
||||
'crd_h',
|
||||
'crd_a',
|
||||
'expgoalshome_value',
|
||||
'expgoalsaway_value',
|
||||
'exp_handicap',
|
||||
'exp_total',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
|
||||
@@ -28,6 +28,8 @@ class StatistikoPlayer extends Model
|
||||
'league_code',
|
||||
'team_code',
|
||||
'team_name',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
|
||||
Reference in new issue
Block a user