From 3d9239737fc311156e37e295f062739b3fc3e8b6 Mon Sep 17 00:00:00 2001 From: salam Date: Sat, 11 Apr 2026 17:40:14 +0200 Subject: [PATCH] statistiko events --- .../Pages/CreateStatistikoEvents.php | 11 ++ .../Pages/EditStatistikoEvents.php | 19 +++ .../Pages/ListStatistikoEvents.php | 40 ++++++ .../Schemas/StatistikoEventsForm.php | 37 ++++++ .../StatistikoEventsResource.php | 56 +++++++++ .../Tables/StatistikoEventsTable.php | 42 +++++++ .../Pages/CreateStatistikoPlayer.php | 11 ++ .../Pages/EditStatistikoPlayers.php | 19 +++ .../Pages/ListStatistikoPlayers.php | 40 ++++++ .../Schemas/StatistikoPlayerForm.php} | 4 +- .../StatistikoPlayerResource.php} | 20 +-- .../Tables/StatistikoPlayersTable.php} | 4 +- .../UbEvents/Pages/CreateUbEvent.php | 11 -- .../Resources/UbEvents/Pages/EditUbEvent.php | 19 --- .../Resources/UbEvents/Pages/ListUbEvents.php | 44 ------- .../UbEvents/Schemas/UbEventForm.php | 94 -------------- .../UbEvents/Tables/UbEventsTable.php | 82 ------------- .../Resources/UbEvents/UbEventResource.php | 71 ----------- .../UbPlayers/Pages/CreateUbPlayer.php | 11 -- .../UbPlayers/Pages/EditUbPlayer.php | 19 --- .../UbPlayers/Pages/ListUbPlayers.php | 56 --------- app/Filament/Imports/PlayerImporter.php | 60 --------- .../Imports/StatistikoEventImporter.php | 104 ++++++++++++++++ ...orter.php => StatistikoPlayerImporter.php} | 14 +-- app/Filament/Imports/UbEventImporter.php | 101 --------------- app/Models/StatistikoEvent.php | 64 ++++++++++ .../{UbPlayer.php => StatistikoPlayer.php} | 17 +-- app/Models/UbEvent.php | 115 ------------------ app/Models/ubevents.txt | 48 -------- 29 files changed, 466 insertions(+), 767 deletions(-) create mode 100644 app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Pages/CreateStatistikoEvents.php create mode 100644 app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Pages/EditStatistikoEvents.php create mode 100644 app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Pages/ListStatistikoEvents.php create mode 100644 app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Schemas/StatistikoEventsForm.php create mode 100644 app/Filament/Clusters/StaticData/Resources/StatistikoEvents/StatistikoEventsResource.php create mode 100644 app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Tables/StatistikoEventsTable.php create mode 100644 app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Pages/CreateStatistikoPlayer.php create mode 100644 app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Pages/EditStatistikoPlayers.php create mode 100644 app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Pages/ListStatistikoPlayers.php rename app/Filament/Clusters/StaticData/Resources/{UbPlayers/Schemas/UbPlayerForm.php => StatistikoPlayers/Schemas/StatistikoPlayerForm.php} (92%) rename app/Filament/Clusters/StaticData/Resources/{UbPlayers/UbPlayerResource.php => StatistikoPlayers/StatistikoPlayerResource.php} (61%) rename app/Filament/Clusters/StaticData/Resources/{UbPlayers/Tables/UbPlayersTable.php => StatistikoPlayers/Tables/StatistikoPlayersTable.php} (95%) delete mode 100644 app/Filament/Clusters/StaticData/Resources/UbEvents/Pages/CreateUbEvent.php delete mode 100644 app/Filament/Clusters/StaticData/Resources/UbEvents/Pages/EditUbEvent.php delete mode 100644 app/Filament/Clusters/StaticData/Resources/UbEvents/Pages/ListUbEvents.php delete mode 100644 app/Filament/Clusters/StaticData/Resources/UbEvents/Schemas/UbEventForm.php delete mode 100644 app/Filament/Clusters/StaticData/Resources/UbEvents/Tables/UbEventsTable.php delete mode 100644 app/Filament/Clusters/StaticData/Resources/UbEvents/UbEventResource.php delete mode 100644 app/Filament/Clusters/StaticData/Resources/UbPlayers/Pages/CreateUbPlayer.php delete mode 100644 app/Filament/Clusters/StaticData/Resources/UbPlayers/Pages/EditUbPlayer.php delete mode 100644 app/Filament/Clusters/StaticData/Resources/UbPlayers/Pages/ListUbPlayers.php delete mode 100644 app/Filament/Imports/PlayerImporter.php create mode 100644 app/Filament/Imports/StatistikoEventImporter.php rename app/Filament/Imports/{UbPlayerImporter.php => StatistikoPlayerImporter.php} (92%) delete mode 100644 app/Filament/Imports/UbEventImporter.php create mode 100644 app/Models/StatistikoEvent.php rename app/Models/{UbPlayer.php => StatistikoPlayer.php} (53%) delete mode 100644 app/Models/UbEvent.php delete mode 100644 app/Models/ubevents.txt diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Pages/CreateStatistikoEvents.php b/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Pages/CreateStatistikoEvents.php new file mode 100644 index 00000000..da0e38c9 --- /dev/null +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Pages/CreateStatistikoEvents.php @@ -0,0 +1,11 @@ +icon('phosphor-trash') + ->requiresConfirmation() + ->color('danger') + ->action(function () { + StatistikoEvent::truncate(); + }), + CreateAction::make() + ->label('New') + ->icon('phosphor-plus'), + ImportAction::make('importEvents') + ->maxRows(200000) + ->color('success') + ->chunkSize(250) + ->icon('phosphor-upload') + ->label('Import') + ->modalDescription('Max 20k rows per import, column separator: ";"') + ->importer(StatistikoEventImporter::class), + ]; + } +} diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Schemas/StatistikoEventsForm.php b/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Schemas/StatistikoEventsForm.php new file mode 100644 index 00000000..1ee4cda8 --- /dev/null +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Schemas/StatistikoEventsForm.php @@ -0,0 +1,37 @@ +components([ + DateTimePicker::make('starttime'), + TextInput::make('season'), + TextInput::make('gls_h'), + TextInput::make('gls_a'), + TextInput::make('crn_h'), + TextInput::make('fls_h'), + TextInput::make('ofs_h'), + TextInput::make('snt_h'), + TextInput::make('tsh_h'), + TextInput::make('crd_h'), + TextInput::make('crn_a'), + TextInput::make('fls_a'), + TextInput::make('ofs_a'), + TextInput::make('snt_a'), + TextInput::make('tsh_a'), + TextInput::make('crd_a'), + TextInput::make('expgoalshome_value'), + TextInput::make('expgoalsaway_value'), + TextInput::make('exp_handicap'), + TextInput::make('exp_total'), + ])->columns(4); + } +} diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/StatistikoEventsResource.php b/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/StatistikoEventsResource.php new file mode 100644 index 00000000..1824579d --- /dev/null +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/StatistikoEventsResource.php @@ -0,0 +1,56 @@ + ListStatistikoEvents::route('/'), + ]; + } + + public static function getNavigationBadge(): ?string + { + return parent::getEloquentQuery()->count(); + } + + public static function getNavigationBadgeColor(): ?string + { + return 'success'; + } +} diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Tables/StatistikoEventsTable.php b/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Tables/StatistikoEventsTable.php new file mode 100644 index 00000000..1fbaccc2 --- /dev/null +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Tables/StatistikoEventsTable.php @@ -0,0 +1,42 @@ +striped() + ->columns([ + IconColumn::make('sport_id') + ->label('') + ->icon(fn (string $state): string => match ($state) { + '1' => 'icon-soccerball', + }), + TextColumn::make('league.name')->searchable(), + TextColumn::make('home.name')->searchable(), + TextColumn::make('away.name')->searchable(), + TextColumn::make('starttime')->dateTime('d. m. Y H:i'), + + ]) + ->filters([ + // + ]) + ->recordActions([ + EditAction::make(), + ]) + ->toolbarActions([ + BulkActionGroup::make([ + DeleteBulkAction::make(), + ]), + ]); + } +} diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Pages/CreateStatistikoPlayer.php b/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Pages/CreateStatistikoPlayer.php new file mode 100644 index 00000000..65f6d48c --- /dev/null +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Pages/CreateStatistikoPlayer.php @@ -0,0 +1,11 @@ +icon('phosphor-trash') + ->requiresConfirmation() + ->color('danger') + ->action(function () { + StatistikoPlayer::truncate(); + }), + CreateAction::make() + ->label('New') + ->icon('phosphor-plus'), + ImportAction::make('importPlayer') + ->maxRows(200000) + ->color('success') + ->chunkSize(250) + ->icon('phosphor-upload') + ->label('Import') + ->modalDescription('Max 20k rows per import, column separator ";"') + ->importer(StatistikoPlayerImporter::class), + ]; + } +} diff --git a/app/Filament/Clusters/StaticData/Resources/UbPlayers/Schemas/UbPlayerForm.php b/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Schemas/StatistikoPlayerForm.php similarity index 92% rename from app/Filament/Clusters/StaticData/Resources/UbPlayers/Schemas/UbPlayerForm.php rename to app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Schemas/StatistikoPlayerForm.php index b5fb1f3f..37edc04b 100644 --- a/app/Filament/Clusters/StaticData/Resources/UbPlayers/Schemas/UbPlayerForm.php +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Schemas/StatistikoPlayerForm.php @@ -1,13 +1,13 @@ ListUbPlayers::route('/'), + 'index' => ListStatistikoPlayers::route('/'), ]; } diff --git a/app/Filament/Clusters/StaticData/Resources/UbPlayers/Tables/UbPlayersTable.php b/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Tables/StatistikoPlayersTable.php similarity index 95% rename from app/Filament/Clusters/StaticData/Resources/UbPlayers/Tables/UbPlayersTable.php rename to app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Tables/StatistikoPlayersTable.php index 72a268b2..16cf662f 100644 --- a/app/Filament/Clusters/StaticData/Resources/UbPlayers/Tables/UbPlayersTable.php +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Tables/StatistikoPlayersTable.php @@ -1,6 +1,6 @@ icon('phosphor-upload') - ->color('success') - ->label('Import') - ->modalIcon('phosphor-file-csv') - ->modalDescription('Separator ";"') - ->modalHeading('Import events with player') - ->importer(UbEventImporter::class) - ->csvDelimiter(';') - ->extraModalFooterActions([ - Action::make('copy') - ->tooltip('Copy header line') - ->color('success') - ->label('Copy') - ->action(function ($livewire) { - $livewire->js('window.navigator.clipboard.writeText("league_id;home_id;away_id;starttime;player_id;home_away;home_ft;away_ft;home_ht;away_ht;Goals;assists;tackles;total_passes;passes_done;total_duels;duels_won;total_ground_duels;ground_duels_won;total_aerial_duels;aerial_duels_won;minutes_played;shots_on_target;shots_off_target;shots_blocked;total_dribble;dribble_done;position;rating;bcm;hw;pw;pm;possession_lost;fouls;was_fouled;offsides;date_acquisition");'); - - Notification::make() - ->title('Header copied successfully') - ->success() - ->send(); - }), - ]), - ]; - } -} diff --git a/app/Filament/Clusters/StaticData/Resources/UbEvents/Schemas/UbEventForm.php b/app/Filament/Clusters/StaticData/Resources/UbEvents/Schemas/UbEventForm.php deleted file mode 100644 index f2712a56..00000000 --- a/app/Filament/Clusters/StaticData/Resources/UbEvents/Schemas/UbEventForm.php +++ /dev/null @@ -1,94 +0,0 @@ -components([ - Section::make('Player Team') - ->schema([ - Radio::make('home_away') - ->hiddenLabel() - ->options([ - 'H' => 'Home', - 'A' => 'Away', - ]), - TextInput::make('rating') - ->numeric() - ->inputMode('decimal'), - ])->columns(2), - Grid::make([ - 'default' => 2, - 'md' => 3, - 'xl' => 5, - ]) - ->schema([ - TextInput::make('home_ft'), - TextInput::make('away_ft'), - TextInput::make('home_ht'), - TextInput::make('away_ht'), - TextInput::make('goals'), - TextInput::make('assists'), - TextInput::make('tackles'), - TextInput::make('total_passes'), - TextInput::make('passes_done'), - TextInput::make('total_duels'), - TextInput::make('duels_won'), - TextInput::make('total_ground_duels'), - TextInput::make('ground_duels_won'), - TextInput::make('total_aerial_duels'), - TextInput::make('aerial_duels_won'), - TextInput::make('minutes_played'), - TextInput::make('shots_on_target'), - TextInput::make('shots_off_target'), - TextInput::make('shots_blocked'), - TextInput::make('total_dribble'), - TextInput::make('dribble_done'), - TextInput::make('position'), - TextInput::make('bcm'), - TextInput::make('hw'), - TextInput::make('pw'), - TextInput::make('pm'), - TextInput::make('possession_lost'), - TextInput::make('fouls'), - TextInput::make('was_fouled'), - TextInput::make('offsides'), - ]), - - ])->columns(1); - } -} -// 'total_passes', -// 'passes_done', -// 'total_duels', -// 'duels_won', -// 'total_ground_duels', -// 'ground_duels_won', -// 'total_aerial_duels', -// 'aerial_duels_won', -// 'minutes_played', -// 'shots_on_target', -// 'shots_off_target', -// 'shots_blocked', -// 'total_dribble', -// 'dribble_done', -// 'position', -// 'rating', -// 'bcm', -// 'hw', -// 'pw', -// 'pm', -// 'possession_lost', -// 'fouls', -// 'was_fouled', -// 'offsides', -// 'date_acquisition', diff --git a/app/Filament/Clusters/StaticData/Resources/UbEvents/Tables/UbEventsTable.php b/app/Filament/Clusters/StaticData/Resources/UbEvents/Tables/UbEventsTable.php deleted file mode 100644 index 5aef1584..00000000 --- a/app/Filament/Clusters/StaticData/Resources/UbEvents/Tables/UbEventsTable.php +++ /dev/null @@ -1,82 +0,0 @@ -poll('10sec') - ->striped() - ->columns([ - TextColumn::make('starttime')->dateTime('d. M. Y')->label('Date'), - TextColumn::make('league.name')->searchable(), - TextColumn::make('home.name')->searchable(), - TextColumn::make('away.name')->searchable(), - // TextColumn::make('player_id')->searchable(), - TextColumn::make('player.name') - ->searchable() - ->copyable() - ->icon('phosphor-copy') - ->iconPosition(IconPosition::After), - TextColumn::make('rating'), - ]) - ->filters([ - Filter::make('created_at') - ->columns(2)->columnSpanFull() - ->schema([ - DatePicker::make('from'), - DatePicker::make('until'), - ]) - ->query(function (Builder $query, array $data): Builder { - return $query - ->when( - $data['from'], - fn (Builder $query, $date): Builder => $query->whereDate('starttime', '>=', $date), - ) - ->when( - $data['until'], - fn (Builder $query, $date): Builder => $query->whereDate('starttime', '<=', $date), - ); - }) - ->indicateUsing(function (array $data): array { - $indicators = []; - - if ($data['from'] ?? null) { - $indicators[] = Indicator::make('Starttime from '.Carbon::parse($data['from'])->toFormattedDateString()) - ->removeField('from'); - } - - if ($data['until'] ?? null) { - $indicators[] = Indicator::make('Starttime until '.Carbon::parse($data['until'])->toFormattedDateString()) - ->removeField('until'); - } - - return $indicators; - }), - ], layout: FiltersLayout::AboveContent) - ->deferFilters(false) - ->recordActions([ - EditAction::make(), - ]) - ->toolbarActions([ - BulkActionGroup::make([ - DeleteBulkAction::make(), - ]), - ]); - } -} diff --git a/app/Filament/Clusters/StaticData/Resources/UbEvents/UbEventResource.php b/app/Filament/Clusters/StaticData/Resources/UbEvents/UbEventResource.php deleted file mode 100644 index b4dd76fb..00000000 --- a/app/Filament/Clusters/StaticData/Resources/UbEvents/UbEventResource.php +++ /dev/null @@ -1,71 +0,0 @@ -starttime->format('d. M. Y').' - '.$record->league->name.' - '.$record->home->name.' vs '.$record->away->name.' - '.$record->player->name; - } - - public static function form(Schema $schema): Schema - { - return UbEventForm::configure($schema); - } - - public static function table(Table $table): Table - { - return UbEventsTable::configure($table); - } - - public static function getPages(): array - { - return [ - 'index' => ListUbEvents::route('/'), - ]; - } - - public static function getNavigationBadge(): ?string - { - return parent::getEloquentQuery()->count(); - } - - public static function getNavigationBadgeColor(): ?string - { - return 'success'; - } -} diff --git a/app/Filament/Clusters/StaticData/Resources/UbPlayers/Pages/CreateUbPlayer.php b/app/Filament/Clusters/StaticData/Resources/UbPlayers/Pages/CreateUbPlayer.php deleted file mode 100644 index 0dd67077..00000000 --- a/app/Filament/Clusters/StaticData/Resources/UbPlayers/Pages/CreateUbPlayer.php +++ /dev/null @@ -1,11 +0,0 @@ -icon('phosphor-trash') - ->requiresConfirmation() - ->color('danger') - ->action(function () { - UbPlayer::truncate(); - }), - CreateAction::make() - ->label('New') - ->icon('phosphor-plus'), - ImportAction::make('importPlayer') - ->maxRows(200000) - ->color('success') - ->chunkSize(250) - ->icon('phosphor-upload') - ->label('Import') - ->modalDescription('Max 20k rows per import, separator comma ","') - ->importer(UbPlayerImporter::class), - // ->extraModalFooterActions([ - // Action::make('copy') - // ->tooltip('Copy header line') - // ->color('success') - // ->label('Copy') - // ->action(function ($livewire) { - // $livewire->js('window.navigator.clipboard.writeText(\'"id giocatore", "giocatore", "data di nascita", "altezza", "nazionalita", "posizione", "sport radar id", "id squadra tm", "nome completo", "giocatore senza caratteri speciali", "rigorista", "national team id", "data aggiornamento", "league_code", "team_code", "team_name"\');'); - - // Notification::make() - // ->title('Header copied successfully') - // ->success() - // ->send(); - // }), - // ]), - - ]; - } -} diff --git a/app/Filament/Imports/PlayerImporter.php b/app/Filament/Imports/PlayerImporter.php deleted file mode 100644 index 190ad106..00000000 --- a/app/Filament/Imports/PlayerImporter.php +++ /dev/null @@ -1,60 +0,0 @@ -castStateUsing(function (string $state): ?int { - if (blank($state)) { - return null; - } - - return (int) $state; - }) - ->requiredMapping() - ->numeric(), - ImportColumn::make('name') - ->castStateUsing(function (string $state): ?string { - if (blank($state)) { - return null; - } - - $state = preg_replace('@\([^\)]*\)$@', '', $state); - - return trim($state); - }) - ->requiredMapping() - ->rules(['required', 'max:255']), - ]; - } - - public function resolveRecord(): Player - { - return Player::firstOrNew([ - 'id' => (int) $this->data['id'], - ]); - } - - public static function getCompletedNotificationBody(Import $import): string - { - $body = 'Your player 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; - } -} diff --git a/app/Filament/Imports/StatistikoEventImporter.php b/app/Filament/Imports/StatistikoEventImporter.php new file mode 100644 index 00000000..fb059ef1 --- /dev/null +++ b/app/Filament/Imports/StatistikoEventImporter.php @@ -0,0 +1,104 @@ +where('sport_id', $this->data['sport_id']) + ->where('league_id', $this->data['league_id']) + ->where('home_id', $this->data['home_id']) + ->where('away_id', $this->data['away_id']) + ->where('starttime', $this->data['starttime']) + ->first(); + if ($res) { + return StatistikoEvent::find($res->id); + } else { + return new StatistikoEvent; + } + } + + public static function getColumns(): array + { + return [ + ImportColumn::make('sport_id')->numeric()->guess(['SPORT']), + ImportColumn::make('league_id')->numeric()->guess(['LEAGUE']), + ImportColumn::make('home_id')->numeric()->guess(['HOME']), + ImportColumn::make('away_id')->numeric()->guess(['AWAY']), + ImportColumn::make('starttime') + ->guess(['STARTTIME']) + ->castStateUsing(function ($state) { + return Carbon::parse($state); + }), + ImportColumn::make('season')->guess(['SEASON']), + ImportColumn::make('gls_h')->numeric(), + ImportColumn::make('gls_a')->numeric(), + ImportColumn::make('crn_h')->numeric(), + ImportColumn::make('fls_h')->numeric(), + ImportColumn::make('ofs_h')->numeric(), + ImportColumn::make('snt_h')->numeric(), + ImportColumn::make('tsh_h')->numeric(), + ImportColumn::make('crd_h')->numeric(), + ImportColumn::make('crn_a')->numeric(), + ImportColumn::make('fls_a')->numeric(), + ImportColumn::make('ofs_a')->numeric(), + ImportColumn::make('snt_a')->numeric(), + ImportColumn::make('tsh_a')->numeric(), + ImportColumn::make('crd_a')->numeric(), + ImportColumn::make('expgoalshome_value') + ->castStateUsing(function (string $state) { + if (blank($state)) { + return null; + } + + return (float) str_replace(',', '.', $state); + }), + ImportColumn::make('expgoalsaway_value') + ->castStateUsing(function (string $state) { + if (blank($state)) { + return null; + } + + return str_replace(',', '.', $state); + }), + ImportColumn::make('exp_handicap') + ->castStateUsing(function (string $state) { + if (blank($state)) { + return null; + } + + return str_replace(',', '.', $state); + }), + ImportColumn::make('exp_total') + ->castStateUsing(function (string $state) { + if (blank($state)) { + return null; + } + + return str_replace(',', '.', $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; + } +} diff --git a/app/Filament/Imports/UbPlayerImporter.php b/app/Filament/Imports/StatistikoPlayerImporter.php similarity index 92% rename from app/Filament/Imports/UbPlayerImporter.php rename to app/Filament/Imports/StatistikoPlayerImporter.php index 4cddda8b..559271d2 100644 --- a/app/Filament/Imports/UbPlayerImporter.php +++ b/app/Filament/Imports/StatistikoPlayerImporter.php @@ -2,31 +2,31 @@ namespace App\Filament\Imports; -use App\Models\UbPlayer; +use App\Models\StatistikoPlayer; use Filament\Actions\Imports\ImportColumn; use Filament\Actions\Imports\Importer; use Filament\Actions\Imports\Models\Import; use Illuminate\Support\Carbon; use Illuminate\Support\Number; -class UbPlayerImporter extends Importer +class StatistikoPlayerImporter extends Importer { - protected static ?string $model = UbPlayer::class; + protected static ?string $model = StatistikoPlayer::class; public static function useDatabaseTransactions(): bool { return false; } - public function resolveRecord(): UbPlayer + public function resolveRecord(): StatistikoPlayer { - $res = UbPlayer::query() + $res = StatistikoPlayer::query() ->where('id_giocatore', $this->data['id_giocatore']) ->first(); if ($res) { - return UbPlayer::find($res->id); + return StatistikoPlayer::find($res->id); } else { - return new UbPlayer; + return new StatistikoPlayer; } } diff --git a/app/Filament/Imports/UbEventImporter.php b/app/Filament/Imports/UbEventImporter.php deleted file mode 100644 index 090b209f..00000000 --- a/app/Filament/Imports/UbEventImporter.php +++ /dev/null @@ -1,101 +0,0 @@ -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; - } -} diff --git a/app/Models/StatistikoEvent.php b/app/Models/StatistikoEvent.php new file mode 100644 index 00000000..e186ea5f --- /dev/null +++ b/app/Models/StatistikoEvent.php @@ -0,0 +1,64 @@ + 'date', + ]; + } + + public function league(): BelongsTo + { + return $this->belongsTo(CompetitionGroup::class, 'league_id', 'id'); + } + + public function home(): BelongsTo + { + return $this->belongsTo(Element::class, 'home_id', 'id'); + } + + public function away(): BelongsTo + { + return $this->belongsTo(Element::class, 'away_id', 'id'); + } +} diff --git a/app/Models/UbPlayer.php b/app/Models/StatistikoPlayer.php similarity index 53% rename from app/Models/UbPlayer.php rename to app/Models/StatistikoPlayer.php index e366334e..0cae3509 100644 --- a/app/Models/UbPlayer.php +++ b/app/Models/StatistikoPlayer.php @@ -6,7 +6,7 @@ namespace App\Models; use MongoDB\Laravel\Eloquent\Model; -class UbPlayer extends Model +class StatistikoPlayer extends Model { protected $connection = 'mongodb'; @@ -33,21 +33,8 @@ class UbPlayer extends Model protected function casts(): array { return [ - 'id_giocatore' => 'string', - 'national_team_id' => 'string', - 'altezza' => 'integer', - 'sport_radar_id' => 'string', - 'id_squadra_tm' => 'string', 'data_di_nascita' => 'date', - 'giocatore' => 'string', - 'nazionalita' => 'string', - 'posizione' => 'string', - 'nome_completo' => 'string', - 'rigorista' => 'string', - 'data_aggiornamento' => 'string', - 'league_code' => 'string', - 'team_code' => 'string', - 'team_name' => 'string', + 'data_aggiornamento' => 'date', ]; } } diff --git a/app/Models/UbEvent.php b/app/Models/UbEvent.php deleted file mode 100644 index c16a0862..00000000 --- a/app/Models/UbEvent.php +++ /dev/null @@ -1,115 +0,0 @@ - 'integer', - 'home_id' => 'integer', - 'away_id' => 'integer', - 'player_id' => 'integer', - 'starttime' => 'date', - 'date_acquisition' => 'date', - 'rating' => 'string', - 'home_away' => 'string', - 'home_ft' => 'integer', - 'away_ft' => 'integer', - 'home_ht' => 'integer', - 'away_ht' => 'integer', - 'goals' => 'integer', - 'assists' => 'integer', - 'tackles' => 'integer', - 'total_passes' => 'integer', - 'passes_done' => 'integer', - 'total_duels' => 'integer', - 'duels_won' => 'integer', - 'total_ground_duels' => 'integer', - 'ground_duels_won' => 'integer', - 'total_aerial_duels' => 'integer', - 'aerial_duels_won' => 'integer', - 'minutes_played' => 'integer', - 'shots_on_target' => 'integer', - 'shots_off_target' => 'integer', - 'shots_blocked' => 'integer', - 'total_dribble' => 'integer', - 'dribble_done' => 'integer', - 'position' => 'integer', - 'bcm' => 'integer', - 'hw' => 'integer', - 'pw' => 'integer', - 'pm' => 'integer', - 'possession_lost' => 'integer', - 'fouls' => 'integer', - 'was_fouled' => 'integer', - 'offsides' => 'integer', - ]; - } - - public function league(): BelongsTo - { - return $this->belongsTo(CompetitionGroup::class, 'league_id', 'id'); - } - - public function home(): BelongsTo - { - return $this->belongsTo(Element::class, 'home_id', 'id'); - } - - public function away(): BelongsTo - { - return $this->belongsTo(Element::class, 'away_id', 'id'); - } -} diff --git a/app/Models/ubevents.txt b/app/Models/ubevents.txt deleted file mode 100644 index 40340498..00000000 --- a/app/Models/ubevents.txt +++ /dev/null @@ -1,48 +0,0 @@ -country_ss -league_ss -home -away -home_ft -away_ft -home_ht -away_ht -date_time_ss -team -player_ss -goals -assists -tackles -total_passes -passes_done -total_duels -duels_won -total_ground_duels -ground_duels_won -total_aerial_duels -aerial_duels_won -minutes_played -shots_on_target -shots_off_target -shots_blocked -total_dribble -dribble_done -position -rating -bcm -hw -pw -pm -possession_ -lost -fouls -was_fouled -offsides -id_player_tm -h_a -date_player_id -date_home_away -id_league -data_di_acquisizione -txleague_id -txhome_id -txaway_id \ No newline at end of file