fix player marcatori names

This commit is contained in:
salam committed 2026-05-11 08:19:25 +02:00
1 parent 3149fa6c12
commit d5563154e0
27 files changed
+508 -339

No files matched your search

@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\StatistikoDetails\Pages;
use App\Filament\Clusters\StaticData\Resources\StatistikoDetails\StatistikoDetailResource;
use Filament\Resources\Pages\CreateRecord;
class CreateStatistikoDetail extends CreateRecord
{
protected static string $resource = StatistikoDetailResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\StatistikoDetails\Pages;
use App\Filament\Clusters\StaticData\Resources\StatistikoDetails\StatistikoDetailResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditStatistikoDetails extends EditRecord
{
protected static string $resource = StatistikoDetailResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\StatistikoDetails\Pages;
use App\Filament\Clusters\StaticData\Resources\StatistikoDetails\StatistikoDetailResource;
use App\Models\StatistikoDetail;
use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListStatistikoDetails extends ListRecords
{
protected static string $resource = StatistikoDetailResource::class;
protected function getHeaderActions(): array
{
return [
Action::make('truncate')
->icon('phosphor-trash')
->requiresConfirmation()
->color('danger')
->action(function () {
StatistikoDetail::truncate();
}),
CreateAction::make()
->label('New')
->icon('phosphor-plus'),
];
}
}
@@ -0,0 +1,38 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\StatistikoDetails\Schemas;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Schema;
class StatistikoDetailForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Grid::make([
'default' => 2,
'xl' => 4,
])->schema([
TextInput::make('id_giocatore')->required(),
TextInput::make('giocatore')->required(),
TextInput::make('nome_completo'),
DatePicker::make('data_di_nascita'),
TextInput::make('altezza'),
TextInput::make('nazionalita'),
TextInput::make('posizione'),
TextInput::make('sport_radar_id'),
TextInput::make('id_squadra_tm'),
TextInput::make('rigorista'),
TextInput::make('national_team_id'),
DatePicker::make('data_aggiornamento'),
TextInput::make('league_code'),
TextInput::make('team_code'),
TextInput::make('team_name'),
]),
])->columns(1);
}
}
@@ -0,0 +1,52 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\StatistikoDetails;
use App\Filament\Clusters\StaticData\Resources\StatistikoDetails\Pages\ListStatistikoDetails;
use App\Filament\Clusters\StaticData\Resources\StatistikoDetails\Schemas\StatistikoDetailForm;
use App\Filament\Clusters\StaticData\Resources\StatistikoDetails\Tables\StatistikoDetailsTable;
use App\Filament\Clusters\StaticData\StaticDataCluster;
use App\Models\StatistikoDetail;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use UnitEnum;
class StatistikoDetailResource extends Resource
{
protected static ?string $model = StatistikoDetail::class;
protected static ?string $navigationLabel = 'Details';
protected static ?string $modelLabel = 'Details';
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
protected static ?string $cluster = StaticDataCluster::class;
protected static ?int $navigationSort = 4;
protected static ?string $recordTitleAttribute = 'giocatore';
public static function form(Schema $schema): Schema
{
return StatistikoDetailForm::configure($schema);
}
public static function table(Table $table): Table
{
return StatistikoDetailsTable::configure($table);
}
public static function getPages(): array
{
return [
'index' => ListStatistikoDetails::route('/'),
];
}
public static function getNavigationBadge(): ?string
{
return parent::getEloquentQuery()->count();
}
}
@@ -0,0 +1,50 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\StatistikoDetails\Tables;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\Layout\Stack;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class StatistikoDetailsTable
{
public static function configure(Table $table): Table
{
return $table
->poll('10sec')
->striped()
->defaultPaginationPageOption(8)
->paginationPageOptions([8, 16, 24, 36])
->columns([
Stack::make([
TextColumn::make('player_id')->prefix('Id: ')->searchable()->color('success')->icon('phosphor-copy')->copyable(),
TextColumn::make('name')->searchable()->prefix('Name: ')->color('primary')->icon('phosphor-copy')->copyable(),
TextColumn::make('full_name')->color('gray')->searchable(),
TextColumn::make('birthdate')->date()->prefix('Birthdate: '),
TextColumn::make('height')->prefix('Height: ')->suffix(' cm'),
TextColumn::make('nationality')->prefix('Nationality: '),
TextColumn::make('position')->prefix('Position: '),
TextColumn::make('sport_radar_id')->searchable()->prefix('Sport Radar Id: ')->icon('phosphor-copy')->copyable(),
TextColumn::make('id_squadra_tm')->prefix('Team Id TM: '),
TextColumn::make('rigorist')->prefix('Rigorist: '),
TextColumn::make('national_team_id')->prefix('National Team Id: '),
TextColumn::make('last_update')->date()->prefix('Last Update: '),
TextColumn::make('created_at')->date()->prefix('Created: '),
TextColumn::make('updated_at')->date()->prefix('Updated: '),
// TextColumn::make('league_code')->prefix('League: '),
// TextColumn::make('team_code')->prefix('Team Code: '),
// TextColumn::make('team_name')->prefix('Team Name: '),
]),
])
->contentGrid([
'md' => 2,
'xl' => 4,
])
->recordActions([
EditAction::make()->hiddenLabel(),
DeleteAction::make()->hiddenLabel(),
]);
}
}
@@ -17,7 +17,7 @@ class StatistikoImportForm
->required()
->allowHtml()
->options([
'personal' => '<span class="text-blue-500">Personals</span>',
'details' => '<span class="text-blue-500">Details</span>',
'events' => '<span class="text-green-500">Events</span>',
'fixtures' => '<span class="text-orange-500">Fixtures</span>',
'player' => '<span class="text-pink-600">Player</span>',
@@ -28,10 +28,10 @@ class StatistikoImportsTable
->width('2rem')
->allowOptionsHtml()
->options([
'personal' => '<span class="text-blue-500">Personal</span>',
'details' => '<span class="text-blue-500">Details</span>',
'events' => '<span class="text-green-500">Events</span>',
'fixtures' => '<span class="text-orange-500">Fixtures</span>',
'player' => '<span class="text-amber-500">Player</span>',
'player' => '<span class="text-pink-600">Player</span>',
]),
TextColumn::make('file_name_original')
->searchable()
@@ -6,7 +6,7 @@ use App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\StatistikoPlaye
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditStatistikoPlayers extends EditRecord
class EditStatistikoPlayer extends EditRecord
{
protected static string $resource = StatistikoPlayerResource::class;
@@ -3,8 +3,6 @@
namespace App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\Pages;
use App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\StatistikoPlayerResource;
use App\Models\StatistikoPlayer;
use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
@@ -15,16 +13,7 @@ class ListStatistikoPlayers extends ListRecords
protected function getHeaderActions(): array
{
return [
Action::make('truncate')
->icon('phosphor-trash')
->requiresConfirmation()
->color('danger')
->action(function () {
StatistikoPlayer::truncate();
}),
CreateAction::make()
->label('New')
->icon('phosphor-plus'),
CreateAction::make(),
];
}
}
@@ -2,7 +2,6 @@
namespace App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\Schemas;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Schema;
@@ -16,25 +15,67 @@ class StatistikoPlayerForm
Grid::make([
'default' => 2,
'xl' => 4,
])
->schema([
TextInput::make('id_giocatore')->required(),
TextInput::make('giocatore')->required(),
TextInput::make('nome_completo'),
DatePicker::make('data_di_nascita'),
TextInput::make('altezza'),
TextInput::make('nazionalita'),
TextInput::make('posizione'),
TextInput::make('sport_radar_id'),
TextInput::make('id_squadra_tm'),
TextInput::make('rigorista'),
TextInput::make('national_team_id'),
DatePicker::make('data_aggiornamento'),
TextInput::make('league_code'),
TextInput::make('team_code'),
TextInput::make('team_name'),
]),
])->schema([
TextInput::make('match_id'),
TextInput::make('player_id'),
TextInput::make('playersubstitute_id'),
TextInput::make('goals'),
TextInput::make('assists'),
TextInput::make('own_goals'),
TextInput::make('shots_on_target'),
TextInput::make('shots_off_target'),
TextInput::make('shots_blocked'),
TextInput::make('fouls'),
TextInput::make('was_fouled'),
TextInput::make('offsides'),
TextInput::make('possessions_lost'),
TextInput::make('total_tackles'),
TextInput::make('touches'),
TextInput::make('total_cross'),
TextInput::make('cross_done'),
TextInput::make('total_dribbles'),
TextInput::make('dribbles_won'),
TextInput::make('total_ground_duels'),
TextInput::make('total_ground_duels_won'),
TextInput::make('total_aerial_duels'),
TextInput::make('total_duels_aerial_won'),
TextInput::make('total_pass'),
TextInput::make('pass'),
TextInput::make('total_long_balls'),
TextInput::make('long_balls'),
TextInput::make('blocked_shots'),
TextInput::make('clearances'),
TextInput::make('dribbled_past'),
TextInput::make('hit_woodwork'),
TextInput::make('interceptions'),
TextInput::make('key_pass'),
TextInput::make('last_man_tackle'),
TextInput::make('dispossessed'),
TextInput::make('clearance_off_line'),
TextInput::make('bcc'),
TextInput::make('bcm'),
TextInput::make('errors_lead_to_a_goal'),
TextInput::make('errors_lead_to_a_shot'),
TextInput::make('penalty_committed'),
TextInput::make('penalty_miss'),
TextInput::make('penalty_save'),
TextInput::make('penalty_won'),
TextInput::make('saves'),
TextInput::make('saves_from_in_box'),
TextInput::make('total_runs_out'),
TextInput::make('runs_out'),
TextInput::make('punches'),
TextInput::make('good_high_claim'),
TextInput::make('minutes_played'),
TextInput::make('lineup'),
TextInput::make('minute_event_during_the_match'),
TextInput::make('type_event_during_the_match'),
TextInput::make('description_event_during_the_match'),
TextInput::make('subtype_event_during_the_match'),
TextInput::make('player_position'),
TextInput::make('playerrating_value'),
TextInput::make('tm_player_id'),
]),
])->columns(1);
}
}
@@ -16,17 +16,17 @@ class StatistikoPlayerResource extends Resource
{
protected static ?string $model = StatistikoPlayer::class;
protected static ?string $navigationLabel = 'Personal Detail';
protected static ?string $navigationLabel = 'Player';
protected static ?string $modelLabel = 'Personal Detail';
protected static ?string $modelLabel = 'Player';
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
protected static ?string $cluster = StaticDataCluster::class;
protected static ?int $navigationSort = 4;
protected static ?int $navigationSort = 5;
protected static ?string $recordTitleAttribute = 'giocatore';
protected static ?string $recordTitleAttribute = 'player.name';
public static function form(Schema $schema): Schema
{
@@ -2,9 +2,9 @@
namespace App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\Tables;
use Filament\Actions\DeleteAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\Layout\Stack;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
@@ -13,38 +13,23 @@ class StatistikoPlayersTable
public static function configure(Table $table): Table
{
return $table
->poll('10sec')
->striped()
->defaultPaginationPageOption(8)
->paginationPageOptions([8, 16, 24, 36])
->columns([
Stack::make([
TextColumn::make('player_id')->prefix('Id: ')->searchable()->color('success')->icon('phosphor-copy')->copyable(),
TextColumn::make('name')->searchable()->prefix('Name: ')->color('primary')->icon('phosphor-copy')->copyable(),
TextColumn::make('full_name')->color('gray')->searchable(),
TextColumn::make('birthdate')->date()->prefix('Birthdate: '),
TextColumn::make('height')->prefix('Height: ')->suffix(' cm'),
TextColumn::make('nationality')->prefix('Nationality: '),
TextColumn::make('position')->prefix('Position: '),
TextColumn::make('sport_radar_id')->searchable()->prefix('Sport Radar Id: ')->icon('phosphor-copy')->copyable(),
TextColumn::make('id_squadra_tm')->prefix('Team Id TM: '),
TextColumn::make('rigorist')->prefix('Rigorist: '),
TextColumn::make('national_team_id')->prefix('National Team Id: '),
TextColumn::make('last_update')->date()->prefix('Last Update: '),
TextColumn::make('created_at')->date()->prefix('Created: '),
TextColumn::make('updated_at')->date()->prefix('Updated: '),
// TextColumn::make('league_code')->prefix('League: '),
// TextColumn::make('team_code')->prefix('Team Code: '),
// TextColumn::make('team_name')->prefix('Team Name: '),
]),
TextColumn::make('match_id')->searchable(),
TextColumn::make('player_id')->searchable(),
TextColumn::make('event.home.name')->searchable(),
TextColumn::make('event.away.name')->searchable(),
TextColumn::make('details.name')->searchable(),
])
->contentGrid([
'md' => 2,
'xl' => 4,
->filters([
//
])
->recordActions([
EditAction::make()->hiddenLabel(),
DeleteAction::make()->hiddenLabel(),
EditAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
]);
}
}
@@ -2,12 +2,12 @@
namespace App\Filament\Imports\Helper;
use App\Models\StatistikoPlayer;
use App\Models\StatistikoDetail;
use Illuminate\Support\Carbon;
use Illuminate\Support\LazyCollection;
use Spatie\SimpleExcel\SimpleExcelReader;
class ImportPersonal
class ImportDetails
{
public static function run(string $filePath): void
{
@@ -22,7 +22,7 @@ class ImportPersonal
$row = array_values($row);
StatistikoPlayer::where('player_id', $row[0])
StatistikoDetail::where('player_id', $row[0])
->update(
[
'name' => $row[1],
@@ -1,52 +0,0 @@
<?php
namespace App\Filament\Imports\Helper;
use App\Models\StatistikoPlayer;
use Illuminate\Support\Carbon;
use Illuminate\Support\LazyCollection;
use Spatie\SimpleExcel\SimpleExcelReader;
class ImportMarcatori
{
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) {
foreach ($chunk as $row) {
$row = array_values($row);
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],
);
}
});
}
}
@@ -0,0 +1,90 @@
<?php
namespace App\Filament\Imports\Helper;
use App\Models\StatistikoPlayer;
use Illuminate\Support\LazyCollection;
use Spatie\SimpleExcel\SimpleExcelReader;
class ImportPlayer
{
public static function run(string $filePath): void
{
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
->getRows()
->chunk(1000)
->each(function (LazyCollection $chunk) {
foreach ($chunk as $row) {
$row = array_values($row);
StatistikoPlayer::where('match_id', $row[0])
->where('player_id', $row[1])
->update(
[
'playersubstitute_id' => $row[2],
'goals' => $row[3],
'assists' => $row[4],
'own_goals' => $row[5],
'shots_on_target' => $row[6],
'shots_off_target' => $row[7],
'shots_blocked' => $row[8],
'fouls' => $row[9],
'was_fouled' => $row[10],
'offsides' => $row[11],
'possessions_lost' => $row[12],
'total_tackles' => $row[13],
'touches' => $row[14],
'total_cross' => $row[15],
'cross_done' => $row[16],
'total_dribbles' => $row[17],
'dribbles_won' => $row[18],
'total_ground_duels' => $row[19],
'total_ground_duels_won' => $row[20],
'total_aerial_duels' => $row[21],
'total_duels_aerial_won' => $row[22],
'total_pass' => $row[23],
'pass' => $row[24],
'total_long_balls' => $row[25],
'long_balls' => $row[26],
'blocked_shots' => $row[27],
'clearances' => $row[28],
'dribbled_past' => $row[29],
'hit_woodwork' => $row[30],
'interceptions' => $row[31],
'key_pass' => $row[32],
'last_man_tackle' => $row[33],
'dispossessed' => $row[34],
'clearance_off_line' => $row[35],
'bcc' => $row[36],
'bcm' => $row[37],
'errors_lead_to_a_goal' => $row[38],
'errors_lead_to_a_shot' => $row[39],
'penalty_committed' => $row[40],
'penalty_miss' => $row[41],
'penalty_save' => $row[42],
'penalty_won' => $row[43],
'saves' => $row[44],
'saves_from_in_box' => $row[45],
'total_runs_out' => $row[46],
'runs_out' => $row[47],
'punches' => $row[48],
'good_high_claim' => $row[49],
'minutes_played' => $row[50],
'lineup' => $row[51],
'minute_event_during_the_match' => $row[52],
'type_event_during_the_match' => $row[53],
'description_event_during_the_match' => $row[54],
'subtype_event_during_the_match' => $row[55],
'player_position' => $row[56],
'playerrating_value' => $row[57],
'tm_player_id' => $row[58],
],
['upsert' => true],
);
}
});
}
}
+5 -3
View File
@@ -3,9 +3,10 @@
namespace App\Filament\Imports;
use App\Filament\Imports\Helper\ImportBenchmark;
use App\Filament\Imports\Helper\ImportDetails;
use App\Filament\Imports\Helper\ImportEvents;
use App\Filament\Imports\Helper\ImportFixtures;
use App\Filament\Imports\Helper\ImportPersonal;
use App\Filament\Imports\Helper\ImportPlayer;
use App\Models\StatistikoImport;
class StatistikoImporter
@@ -31,8 +32,8 @@ class StatistikoImporter
ImportBenchmark::start($table);
switch ($record['data_type']) {
case 'personal':
ImportPersonal::run($filePath);
case 'details':
ImportDetails::run($filePath);
break;
case 'events':
ImportEvents::run($filePath);
@@ -41,6 +42,7 @@ class StatistikoImporter
ImportFixtures::run($filePath);
break;
case 'player':
ImportPlayer::run($filePath);
break;
}