From 6ecee8635a6978bb6f3098fd2866559863109b3e Mon Sep 17 00:00:00 2001 From: salam Date: Thu, 17 Sep 2026 16:03:08 +0200 Subject: [PATCH] wip --- app/Filament/Pages/PlayerProps.php | 30 +++++++++++++++--------- app/Filament/Widgets/PlayerPropsDrop.php | 28 ++++++++++++++++++---- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/app/Filament/Pages/PlayerProps.php b/app/Filament/Pages/PlayerProps.php index 8f7d9b95..5912b599 100644 --- a/app/Filament/Pages/PlayerProps.php +++ b/app/Filament/Pages/PlayerProps.php @@ -34,7 +34,7 @@ class PlayerProps extends Page implements HasForms ->group(static::getNavigationGroup()) ->icon(static::getNavigationIcon()) ->activeIcon(static::getActiveNavigationIcon()) - ->isActiveWhen(fn() => request()->routeIs(static::getRouteName())) + ->isActiveWhen(fn () => request()->routeIs(static::getRouteName())) ->sort(static::getNavigationSort()) ->url(static::getUrl(), shouldOpenInNewTab: true), // 👈 Forces target="_blank" ]; @@ -58,6 +58,7 @@ class PlayerProps extends Page implements HasForms public string $activeLineUp = '3313'; public array $players = []; + public array $clientLineUps = []; public int $team_id; @@ -84,46 +85,48 @@ class PlayerProps extends Page implements HasForms ->live() ->preload() ->searchable(false) - ->prefixIconColor(fn(Get $get): string => $get('cid') ? 'success' : 'danger') + ->prefixIconColor(fn (Get $get): string => $get('cid') ? 'success' : 'danger') ->prefixIcon('phosphor-globe-fill') ->hiddenLabel() - ->options(fn() => LoadSofaScoreCategory::load()) + ->options(fn () => LoadSofaScoreCategory::load()) ->placeholder('Country') ->afterStateUpdated(function (callable $set, $state) { $set('lid', null); $set('mid', null); $set('tid', null); + $this->dispatch('clear-all'); }), Select::make('lid') ->live() ->preload() - ->prefixIconColor(fn(Get $get): string => $get('lid') ? 'success' : 'danger') + ->prefixIconColor(fn (Get $get): string => $get('lid') ? 'success' : 'danger') ->prefixIcon('phosphor-trophy-fill') ->hiddenLabel() - ->options(fn(Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('cid'))) + ->options(fn (Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('cid'))) ->placeholder('League') ->afterStateUpdated(function (callable $set) { $set('mid', null); $set('tid', null); + $this->dispatch('clear-all'); }), Select::make('mid') ->live() ->hiddenLabel() - ->prefixIconColor(fn(Get $get): string => $get('mid') ? 'success' : 'danger') + ->prefixIconColor(fn (Get $get): string => $get('mid') ? 'success' : 'danger') ->prefixIcon('phosphor-calendar-check-fill') ->options(function (Get $get) { return LoadStatisticFixturesMatchOptions::load($get('lid')); }) ->afterStateUpdated(function (callable $set, $state) { - $this->dispatch('match-update', match_id: $state); $set('tid', null); + $this->dispatch('match-update', match_id: $state); }) ->placeholder('Events'), Select::make('tid') ->live() ->hiddenLabel() - ->prefixIconColor(fn(Get $get): string => $get('tid') ? 'success' : 'danger') + ->prefixIconColor(fn (Get $get): string => $get('tid') ? 'success' : 'danger') ->prefixIcon('icon-player') ->options(function (Get $get) { if ($get('mid')) { @@ -153,11 +156,13 @@ class PlayerProps extends Page implements HasForms $res = $this->lineUpOptinos(); $arr = []; foreach ($res as $key => $value) { - if ($this->players && in_array($key, $this->clientLineUps)) - $arr[$key] = $value . ' has lineup'; - else + if ($this->players && in_array($key, $this->clientLineUps)) { + $arr[$key] = $value.' has lineup'; + } else { $arr[$key] = $value; + } } + return $arr; }) ->placeholder('LineUp') @@ -181,6 +186,7 @@ class PlayerProps extends Page implements HasForms { $this->players = $players; } + protected function getFooterWidgets(): array { return [ @@ -188,10 +194,12 @@ class PlayerProps extends Page implements HasForms PlayerPropsDrop::make(['players' => $this->players]), ]; } + public function getFooterWidgetsColumns(): int|array { return 5; } + private function lineUpOptinos(): array { return [ diff --git a/app/Filament/Widgets/PlayerPropsDrop.php b/app/Filament/Widgets/PlayerPropsDrop.php index 88df3225..2ea37b80 100644 --- a/app/Filament/Widgets/PlayerPropsDrop.php +++ b/app/Filament/Widgets/PlayerPropsDrop.php @@ -71,11 +71,28 @@ class PlayerPropsDrop extends Widget $this->lineup = $this->lineUpMap[$this->activeLineUp]; } - #[On('match-update')] - public function matchUpdate(int $match_id) + #[On('clear-all')] + public function clearAll() { - $this->match_id = $match_id; - $this->loadPlacement(); + $this->team_name = ''; + $this->match_id = 0; + for ($i = 1; $i <= 35; $i++) { + $this->boxes[$i] = []; + } + $this->players = []; + $this->dispatch('update-players', players: $this->players); + } + + #[On('match-update')] + public function matchUpdate(?int $match_id) + { + $this->clearResultTable(); + $this->players = []; + if ($match_id) { + $this->match_id = $match_id; + } else { + $this->team_name = ''; + } } #[On('team-update')] @@ -234,10 +251,13 @@ class PlayerPropsDrop extends Widget public function clearResultTable(): void { + for ($i = 1; $i <= 35; $i++) { $this->boxes[$i] = []; } + foreach ($this->players as $k => $record) { + // $this->players[$k] = []; $this->players[$k]['active'] = 0; $this->players[$k]['gls'] = ''; $this->players[$k]['fls'] = '';