From 095a4ffd416e76f2f5134c069cb538978ffd43cf Mon Sep 17 00:00:00 2001 From: salam Date: Sat, 30 May 2026 18:48:15 +0200 Subject: [PATCH] wip chart in tab --- app/Filament/Pages/Statistic.php | 65 ++++++++----------- app/Filament/Widgets/ChartEvent.php | 9 ++- app/Filament/Widgets/ChartEventMoAv.php | 5 +- app/Filament/Widgets/ChartEventPerf.php | 5 +- app/Filament/Widgets/ChartEventPerfMoAv.php | 5 +- app/Filament/Widgets/ChartPlayer.php | 5 +- app/Filament/Widgets/ChartPlayerMoAv.php | 5 +- app/Filament/Widgets/ChartPlayerPerf.php | 5 +- app/Filament/Widgets/ChartPlayerPerfMoAv.php | 5 +- app/Filament/Widgets/Data/LoadPerformance.php | 25 ------- app/Filament/Widgets/StatsMedianAverage.php | 12 +++- .../views/filament/pages/statistic.blade.php | 49 ++++++++++++++ 12 files changed, 109 insertions(+), 86 deletions(-) diff --git a/app/Filament/Pages/Statistic.php b/app/Filament/Pages/Statistic.php index 1eb9e77d..8ad54432 100644 --- a/app/Filament/Pages/Statistic.php +++ b/app/Filament/Pages/Statistic.php @@ -4,15 +4,6 @@ namespace App\Filament\Pages; use App\Actions\LoadStatisticFixturesLeaguesOptions; use App\Actions\LoadStatisticFixturesMatchOptions; -use App\Filament\Widgets\ChartEvent; -use App\Filament\Widgets\ChartEventMoAv; -use App\Filament\Widgets\ChartEventPerf; -use App\Filament\Widgets\ChartEventPerfMoAv; -use App\Filament\Widgets\ChartPlayer; -use App\Filament\Widgets\ChartPlayerMoAv; -use App\Filament\Widgets\ChartPlayerPerf; -use App\Filament\Widgets\ChartPlayerPerfMoAv; -use App\Filament\Widgets\StatsMedianAverage; use App\Models\Element; use App\Models\StatisticFixtures; use App\Models\StatistikoDetail; @@ -36,6 +27,10 @@ class Statistic extends BaseDashboard protected static string|BackedEnum|null $navigationIcon = 'phosphor-chart-line-up'; + protected string $view = 'filament.pages.statistic'; + + protected string $activeTab = 'tab1'; + protected ?string $pollingInterval = null; protected static ?string $title = 'Statistic'; @@ -45,24 +40,34 @@ class Statistic extends BaseDashboard 'xl' => 3, ]; + public function getActiveTab() + { + return $this->activeTab; + } + public function getHeading(): string|Htmlable|null { return ''; } - protected function getHeaderActions(): array + public function updatedFilter($value) // Or whatever your property name is { - return [ - Action::make('collapseAll') - ->label('Collapse All Charts') - ->icon('heroicon-m-chevron-up') - ->color('gray') - ->action(function ($record, $livewire) { - $livewire->dispatch('collapse-all-charts'); - }), - ]; + $this->dispatch('filterChanged', filterValue: $value); } + // protected function getHeaderActions(): array + // { + // return [ + // Action::make('collapseAll') + // ->label('Collapse All Charts') + // ->icon('heroicon-m-chevron-up') + // ->color('gray') + // ->action(function ($record, $livewire) { + // $livewire->dispatch('collapse-all-charts'); + // }), + // ]; + // } + public function filtersForm(Schema $schema): Schema { return $schema @@ -84,8 +89,9 @@ class Statistic extends BaseDashboard ->options(fn () => LoadStatisticFixturesLeaguesOptions::load(1)) ->live() ->label('League') - ->afterStateUpdated(function (callable $set) { + ->afterStateUpdated(function (callable $set, $state) { $set('match_id', null); + $this->dispatch('filterChanged', filterValue: $state); }), Select::make('match_id') ->prefixIconColor('primary') @@ -247,25 +253,6 @@ class Statistic extends BaseDashboard return [ 'default' => 1, 'md' => 2, - 'lg' => 4, - ]; - } - - protected function getFooterWidgets(): array - { - return [ - StatsMedianAverage::make(), - - // Events - ChartEvent::make(), - ChartEventMoAv::make(), - ChartEventPerf::make(), - ChartEventPerfMoAv::make(), - // Players - ChartPlayer::make(), - ChartPlayerMoAv::make(), - ChartPlayerPerf::make(), - ChartPlayerPerfMoAv::make(), ]; } diff --git a/app/Filament/Widgets/ChartEvent.php b/app/Filament/Widgets/ChartEvent.php index 500195af..98a0ed70 100644 --- a/app/Filament/Widgets/ChartEvent.php +++ b/app/Filament/Widgets/ChartEvent.php @@ -6,19 +6,18 @@ use App\Filament\Widgets\Data\HelperStatisticType; use App\Filament\Widgets\Data\LoadEvents; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; -use Filament\Widgets\Concerns\InteractsWithPageFilters; +use Livewire\Attributes\Reactive; class ChartEvent extends ChartWidget { - use InteractsWithPageFilters; - - // protected string $view = 'filament.widgets.custom-chart-widget'; + #[Reactive] + public ?array $filters = []; protected ?string $heading = 'Events'; protected ?string $pollingInterval = null; - protected bool $isCollapsible = true; + protected bool $isCollapsible = false; protected $f; diff --git a/app/Filament/Widgets/ChartEventMoAv.php b/app/Filament/Widgets/ChartEventMoAv.php index c4e568d8..88ef0adf 100644 --- a/app/Filament/Widgets/ChartEventMoAv.php +++ b/app/Filament/Widgets/ChartEventMoAv.php @@ -7,11 +7,12 @@ use App\Filament\Widgets\Data\HelperStatisticType; use App\Filament\Widgets\Data\LoadEvents; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; -use Filament\Widgets\Concerns\InteractsWithPageFilters; +use Livewire\Attributes\Reactive; class ChartEventMoAv extends ChartWidget { - use InteractsWithPageFilters; + #[Reactive] + public ?array $filters = []; protected ?string $heading = 'Events'; diff --git a/app/Filament/Widgets/ChartEventPerf.php b/app/Filament/Widgets/ChartEventPerf.php index 0a461b89..1aa47c8b 100644 --- a/app/Filament/Widgets/ChartEventPerf.php +++ b/app/Filament/Widgets/ChartEventPerf.php @@ -5,11 +5,12 @@ namespace App\Filament\Widgets; use App\Filament\Widgets\Data\LoadPerformance; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; -use Filament\Widgets\Concerns\InteractsWithPageFilters; +use Livewire\Attributes\Reactive; class ChartEventPerf extends ChartWidget { - use InteractsWithPageFilters; + #[Reactive] + public ?array $filters = []; protected ?string $heading = 'Events'; diff --git a/app/Filament/Widgets/ChartEventPerfMoAv.php b/app/Filament/Widgets/ChartEventPerfMoAv.php index db84bcd8..c5d01a99 100644 --- a/app/Filament/Widgets/ChartEventPerfMoAv.php +++ b/app/Filament/Widgets/ChartEventPerfMoAv.php @@ -6,11 +6,12 @@ use App\Filament\Widgets\Data\HelperMoveingAveragePerformens; use App\Filament\Widgets\Data\LoadPerformance; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; -use Filament\Widgets\Concerns\InteractsWithPageFilters; +use Livewire\Attributes\Reactive; class ChartEventPerfMoAv extends ChartWidget { - use InteractsWithPageFilters; + #[Reactive] + public ?array $filters = []; protected ?string $heading = 'Events'; diff --git a/app/Filament/Widgets/ChartPlayer.php b/app/Filament/Widgets/ChartPlayer.php index cd8c0629..5e1ee6b1 100644 --- a/app/Filament/Widgets/ChartPlayer.php +++ b/app/Filament/Widgets/ChartPlayer.php @@ -5,11 +5,12 @@ namespace App\Filament\Widgets; use App\Filament\Widgets\Data\LoadPlayer; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; -use Filament\Widgets\Concerns\InteractsWithPageFilters; +use Livewire\Attributes\Reactive; class ChartPlayer extends ChartWidget { - use InteractsWithPageFilters; + #[Reactive] + public ?array $filters = []; protected ?string $pollingInterval = null; diff --git a/app/Filament/Widgets/ChartPlayerMoAv.php b/app/Filament/Widgets/ChartPlayerMoAv.php index 90e751ad..98b8233b 100644 --- a/app/Filament/Widgets/ChartPlayerMoAv.php +++ b/app/Filament/Widgets/ChartPlayerMoAv.php @@ -6,11 +6,12 @@ use App\Filament\Widgets\Data\HelperMoveingAverage; use App\Filament\Widgets\Data\LoadPlayer; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; -use Filament\Widgets\Concerns\InteractsWithPageFilters; +use Livewire\Attributes\Reactive; class ChartPlayerMoAv extends ChartWidget { - use InteractsWithPageFilters; + #[Reactive] + public ?array $filters = []; protected ?string $pollingInterval = null; diff --git a/app/Filament/Widgets/ChartPlayerPerf.php b/app/Filament/Widgets/ChartPlayerPerf.php index 6831173e..86309ba2 100644 --- a/app/Filament/Widgets/ChartPlayerPerf.php +++ b/app/Filament/Widgets/ChartPlayerPerf.php @@ -3,11 +3,12 @@ namespace App\Filament\Widgets; use Filament\Widgets\ChartWidget; -use Filament\Widgets\Concerns\InteractsWithPageFilters; +use Livewire\Attributes\Reactive; class ChartPlayerPerf extends ChartWidget { - use InteractsWithPageFilters; + #[Reactive] + public ?array $filters = []; protected ?string $heading = 'Player'; diff --git a/app/Filament/Widgets/ChartPlayerPerfMoAv.php b/app/Filament/Widgets/ChartPlayerPerfMoAv.php index a97cbf04..1c812881 100644 --- a/app/Filament/Widgets/ChartPlayerPerfMoAv.php +++ b/app/Filament/Widgets/ChartPlayerPerfMoAv.php @@ -3,11 +3,12 @@ namespace App\Filament\Widgets; use Filament\Widgets\ChartWidget; -use Filament\Widgets\Concerns\InteractsWithPageFilters; +use Livewire\Attributes\Reactive; class ChartPlayerPerfMoAv extends ChartWidget { - use InteractsWithPageFilters; + #[Reactive] + public ?array $filters = []; protected ?string $heading = 'Player'; diff --git a/app/Filament/Widgets/Data/LoadPerformance.php b/app/Filament/Widgets/Data/LoadPerformance.php index 6a4dda2a..79d31e48 100644 --- a/app/Filament/Widgets/Data/LoadPerformance.php +++ b/app/Filament/Widgets/Data/LoadPerformance.php @@ -3,7 +3,6 @@ namespace App\Filament\Widgets\Data; use App\Models\StatisticFixtures; -use App\Models\StatistikoDetail; use App\Models\StatistikoEvent; use App\Models\StatistikoPlayer; use Illuminate\Support\Carbon; @@ -146,30 +145,6 @@ class LoadPerformance return $data; - /** - * IF WITH PLAYER - */ - // $matches_played = 0; - // $description = ''; - // if ($tm_player_id) { - // $matches_played = StatistikoPlayer::where('tm_player_id', (int) $tm_player_id) - // ->when($player_on_field, function ($query) use ($player_on_field) { - // switch ($player_on_field) { - // case 'lineup': - // return $query->where('lineup', 'T'); - // case 'substituted': - // return $query->where('lineup', 'P'); - // } - // }) - // ->pluck('match_id')->toArray(); - - // if (! $matches_played) { - // return []; - // } - - // $description = ' (with '.StatistikoDetail::where('tm_player_id', (int) $tm_player_id)->value('name').')'; - // } - } public static function filterMatches($res, $matches) diff --git a/app/Filament/Widgets/StatsMedianAverage.php b/app/Filament/Widgets/StatsMedianAverage.php index daba981c..697dc1d4 100644 --- a/app/Filament/Widgets/StatsMedianAverage.php +++ b/app/Filament/Widgets/StatsMedianAverage.php @@ -5,16 +5,22 @@ namespace App\Filament\Widgets; use App\Filament\Widgets\Data\HelperStatisticType; use App\Filament\Widgets\Data\LoadEvents; use App\Utilities\Round; -use Filament\Widgets\Concerns\InteractsWithPageFilters; use Filament\Widgets\StatsOverviewWidget; use Filament\Widgets\StatsOverviewWidget\Stat; +use Livewire\Attributes\Reactive; class StatsMedianAverage extends StatsOverviewWidget { - use InteractsWithPageFilters; - protected ?string $pollingInterval = null; + #[Reactive] + public ?array $filters = []; + + public function mount(array $filters) + { + $this->filters = $filters; + } + public function getColumns(): int|array { return [ diff --git a/resources/views/filament/pages/statistic.blade.php b/resources/views/filament/pages/statistic.blade.php index 166e4fa1..86527c3d 100644 --- a/resources/views/filament/pages/statistic.blade.php +++ b/resources/views/filament/pages/statistic.blade.php @@ -1,2 +1,51 @@ + {{ $this->filtersForm }} + + @livewire(\App\Filament\Widgets\StatsMedianAverage::class, ['filters' => $this->filters]) + +
+ + + + Events + + + + Events Performance + + + + Player + + + + Player Performance + + + + +
+ +
+ @livewire(\App\Filament\Widgets\ChartEvent::class, ['filters' => $this->filters]) + @livewire(\App\Filament\Widgets\ChartEventMoAv::class, ['filters' => $this->filters]) +
+ + +
+ @livewire(\App\Filament\Widgets\ChartEventPerf::class, ['filters' => $this->filters]) + @livewire(\App\Filament\Widgets\ChartEventPerfMoAv::class, ['filters' => $this->filters]) +
+ +
+ @livewire(\App\Filament\Widgets\ChartPlayer::class, ['filters' => $this->filters]) + @livewire(\App\Filament\Widgets\ChartPlayerMoAv::class, ['filters' => $this->filters]) +
+ +
+ @livewire(\App\Filament\Widgets\ChartPlayerPerf::class, ['filters' => $this->filters]) + @livewire(\App\Filament\Widgets\ChartPlayerPerfMoAv::class, ['filters' => $this->filters]) +
+
+