From 27badf91400586a6e6dcb3367c8614811dd790ad Mon Sep 17 00:00:00 2001 From: salam Date: Sat, 23 May 2026 17:14:58 +0200 Subject: [PATCH] wip --- app/Filament/Pages/Statistic.php | 3 ++- .../Widgets/Data/HelperMoveingAverage.php | 2 +- app/Filament/Widgets/Data/LoadEvents.php | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/Filament/Pages/Statistic.php b/app/Filament/Pages/Statistic.php index 7e68100c..15d254d0 100644 --- a/app/Filament/Pages/Statistic.php +++ b/app/Filament/Pages/Statistic.php @@ -153,7 +153,8 @@ class Statistic extends BaseDashboard 'all' => 'All', 'lineup' => 'Lineup', 'substituted' => 'Substituted', - ]), + ]) + ->live(), Select::make('statistic_type') ->prefixIcon('phosphor-cell-signal-full') ->default('none') diff --git a/app/Filament/Widgets/Data/HelperMoveingAverage.php b/app/Filament/Widgets/Data/HelperMoveingAverage.php index c325d601..83481ec3 100644 --- a/app/Filament/Widgets/Data/HelperMoveingAverage.php +++ b/app/Filament/Widgets/Data/HelperMoveingAverage.php @@ -14,7 +14,7 @@ class HelperMoveingAverage $new = []; $last = count($arr); foreach ($arr as $key => $value) { - if ($key == 1) { + if ($key == 1 && $last > 2) { $new[] = round(($arr[0] + $value + $arr[2]) / 3, 1); } elseif ($key > 1 && $key < $last - 1) { $new[] = round(($arr[$key - 1] + $value + $arr[$key + 1]) / 3, 1); diff --git a/app/Filament/Widgets/Data/LoadEvents.php b/app/Filament/Widgets/Data/LoadEvents.php index 6623c6b4..028a89f8 100644 --- a/app/Filament/Widgets/Data/LoadEvents.php +++ b/app/Filament/Widgets/Data/LoadEvents.php @@ -33,6 +33,8 @@ class LoadEvents $team_position = $filter['team_position']; + $player_on_field = $filter['player_on_field']; + if (! $league_id) { return []; } @@ -49,7 +51,20 @@ class LoadEvents $matches_played = 0; $description = ''; if ($tm_player_id) { - $matches_played = StatistikoPlayer::where('tm_player_id', (int) $tm_player_id)->pluck('match_id')->toArray(); + $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').')'; }