From 958944f21c4c309be8daf14e3fe1f74983426b52 Mon Sep 17 00:00:00 2001 From: salam Date: Tue, 15 Sep 2026 11:26:16 +0200 Subject: [PATCH] wip --- app/Filament/Imports/Helper/ImportDetails.php | 18 ++++++++++-------- app/Filament/Widgets/PlayerPropsDrop.php | 5 ++++- app/Filament/Widgets/PlayerPropsTable.php | 5 +++-- app/Livewire/PlayerCalculator.php | 6 ++++++ .../tables/columns/drag-card.blade.php | 8 ++++---- .../views/livewire/player-props-drop.blade.php | 4 +++- 6 files changed, 30 insertions(+), 16 deletions(-) diff --git a/app/Filament/Imports/Helper/ImportDetails.php b/app/Filament/Imports/Helper/ImportDetails.php index 566da27d..3a25181e 100644 --- a/app/Filament/Imports/Helper/ImportDetails.php +++ b/app/Filament/Imports/Helper/ImportDetails.php @@ -11,7 +11,7 @@ class ImportDetails { public static function run(string $filePath): void { - StatistikoDetail::query()->update(['last_import' => 'out']); + StatistikoDetail::query()->update(['last_import' => 'no']); SimpleExcelReader::create(storage_path('app/public/'.$filePath)) ->getRows() @@ -20,12 +20,14 @@ class ImportDetails $collection = []; foreach ($chunk as $row) { - $row['is_active'] = 1; - $row['last_import'] = 'in'; - $row['birthdate'] = isset($row['birthday']) ? Carbon::parse($row['birthday'])->format('Y-m-d') : ''; - unset($row['birthday']); - $row['last_update'] = Carbon::parse($row['last_update'])->format('Y-m-d H:i:s'); - $collection[] = $row; + if ($row['player_name'] != '') { + $row['is_active'] = 1; + $row['last_import'] = 'yes'; + $row['birthdate'] = isset($row['birthday']) ? Carbon::parse($row['birthday'])->format('Y-m-d') : ''; + unset($row['birthday']); + $row['last_update'] = Carbon::parse($row['last_update'])->format('Y-m-d H:i:s'); + $collection[] = $row; + } } StatistikoDetail::upsert( @@ -48,6 +50,6 @@ class ImportDetails ]); }); - StatistikoDetail::where('last_import', 'out')->update(['is_active' => 0, 'ss_team_id' => 0]); + StatistikoDetail::where('last_import', 'no')->update(['is_active' => 0, 'ss_team_id' => 0]); } } diff --git a/app/Filament/Widgets/PlayerPropsDrop.php b/app/Filament/Widgets/PlayerPropsDrop.php index 514fcec1..c8a552e7 100644 --- a/app/Filament/Widgets/PlayerPropsDrop.php +++ b/app/Filament/Widgets/PlayerPropsDrop.php @@ -70,6 +70,7 @@ class PlayerPropsDrop extends Widget public function matchUpdate(int $match_id) { $this->match_id = $match_id; + $this->loadPlacement(); } #[On('team-update')] @@ -159,7 +160,7 @@ class PlayerPropsDrop extends Widget } } } - $this->dispatch('update-players', players: $this->players); + $this->calculateAspg(); } public function storePlacement() @@ -325,6 +326,8 @@ class PlayerPropsDrop extends Widget $this->players[$k]['crd'] = ''; } + $this->dispatch('update-players', players: $this->players); + if ($manual) { Notification::make()->title('Calculation needs 10 player on field') ->info() diff --git a/app/Filament/Widgets/PlayerPropsTable.php b/app/Filament/Widgets/PlayerPropsTable.php index 69cacf34..77a83beb 100644 --- a/app/Filament/Widgets/PlayerPropsTable.php +++ b/app/Filament/Widgets/PlayerPropsTable.php @@ -18,6 +18,7 @@ class PlayerPropsTable extends TableWidget use InteractsWithForms; protected int|string|array $columnSpan = 2; + public int $team_id; public array $players; @@ -56,7 +57,7 @@ class PlayerPropsTable extends TableWidget ->emptyStateHeading('No team selected') ->columns([ ViewColumn::make('drag_card') - ->label(fn() => $this->getHeadingTable()) + ->label(fn () => $this->getHeadingTable()) ->view('filament.tables.columns.drag-card'), ])->extraAttributes([ 'id' => 'playerdragtable', @@ -86,7 +87,7 @@ class PlayerPropsTable extends TableWidget ], layout: FiltersLayout::AboveContent) ->deferFilters(false) ->records(function () { - $collection = collect($this->players); + $collection = collect($this->players)->sortBy('order'); $selectedPosition = $this->tableFilters['positions']['area'] ?? null; if (! empty($selectedPosition)) { $collection = $collection->where('area', $selectedPosition); diff --git a/app/Livewire/PlayerCalculator.php b/app/Livewire/PlayerCalculator.php index 5b751793..45b80b07 100644 --- a/app/Livewire/PlayerCalculator.php +++ b/app/Livewire/PlayerCalculator.php @@ -55,22 +55,28 @@ class PlayerCalculator extends Component if (! isset($val->details)) { $tmp['area'] = 'goalkeeper'; $tmp['color_pos'] = 'gray'; + $tmp['order'] = 5; } else { if (in_array($val->details->position, $positions_map['MIDFIELD'])) { $tmp['area'] = 'midfield'; $tmp['color_pos'] = 'info'; + $tmp['order'] = 2; } elseif (in_array($val->details->position, $positions_map['DEFENCE'])) { $tmp['area'] = 'defence'; $tmp['color_pos'] = 'success'; + $tmp['order'] = 1; } elseif (in_array($val->details->position, $positions_map['ATTACK'])) { $tmp['area'] = 'attack'; $tmp['color_pos'] = 'warning'; + $tmp['order'] = 3; } elseif (in_array($val->details->position, $positions_map['GOALKEEPER'])) { $tmp['area'] = 'goalkeeper'; $tmp['color_pos'] = 'gray'; + $tmp['order'] = 4; } else { $tmp['area'] = 'defence'; $tmp['color_pos'] = 'success'; + $tmp['order'] = 5; } } diff --git a/resources/views/filament/tables/columns/drag-card.blade.php b/resources/views/filament/tables/columns/drag-card.blade.php index b9c24a84..3c341184 100644 --- a/resources/views/filament/tables/columns/drag-card.blade.php +++ b/resources/views/filament/tables/columns/drag-card.blade.php @@ -14,12 +14,12 @@
{{ $record['foot'] }}
{{ $record['tot_evt'] }}
{{ $record['ave_min'] }}
-
{{ $record['pos'] }}
+
{{ $record['pos'] }}
-
- +
+
{{ ucfirst($record['pos_ori']) }} - +
{{ $record['name'] }} diff --git a/resources/views/livewire/player-props-drop.blade.php b/resources/views/livewire/player-props-drop.blade.php index 9a974780..c593af68 100644 --- a/resources/views/livewire/player-props-drop.blade.php +++ b/resources/views/livewire/player-props-drop.blade.php @@ -22,12 +22,14 @@
- + + + {{-- --}}