From f850c114ab2a8dc9b57acbbd3329d52a4e4307ae Mon Sep 17 00:00:00 2001 From: salam Date: Fri, 14 Aug 2026 20:04:57 +0200 Subject: [PATCH] show second box only if $team_id --- .../Data/LoadEvents/LoadExpectations.php | 5 ++-- app/Filament/Widgets/StatsMedianAverage.php | 26 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/Filament/Widgets/Data/LoadEvents/LoadExpectations.php b/app/Filament/Widgets/Data/LoadEvents/LoadExpectations.php index c11519ae..995adc0d 100644 --- a/app/Filament/Widgets/Data/LoadEvents/LoadExpectations.php +++ b/app/Filament/Widgets/Data/LoadEvents/LoadExpectations.php @@ -2,7 +2,6 @@ namespace App\Filament\Widgets\Data\LoadEvents; -use App\Models\StatisticFixtures; use App\Models\StatistikoConfig; class LoadExpectations @@ -96,7 +95,7 @@ class LoadExpectations $count_home += \count($h_got_h); $count_home = !$count_home ? 1 : $count_home; - $aspettativa_home = round($summe_home / $count_home, 2); + $aspettativa_home = round($summe_home / $count_home, 1); $summe_away = array_sum($a_made_t) * $away_made_total; $summe_away += array_sum($a_made_a) * $away_made_home; @@ -108,7 +107,7 @@ class LoadExpectations $count_away += \count($a_got_a); $count_away = !$count_away ? 1 : $count_away; - $aspettativa_away = round($summe_away / $count_away, 2); + $aspettativa_away = round($summe_away / $count_away, 1); return ['home' => $aspettativa_home, 'away' => $aspettativa_away]; } diff --git a/app/Filament/Widgets/StatsMedianAverage.php b/app/Filament/Widgets/StatsMedianAverage.php index 23b2ac86..bc7f139f 100644 --- a/app/Filament/Widgets/StatsMedianAverage.php +++ b/app/Filament/Widgets/StatsMedianAverage.php @@ -34,6 +34,8 @@ class StatsMedianAverage extends StatsOverviewWidget { $data = LoadEvents::load($this->filters, false); + $team_id = (int) $this->filters['team_id'] ?? 0; + // Log::debug($data['datasets']); $team_position = HelperTeamPosition::get($this->filters); @@ -64,16 +66,16 @@ class StatsMedianAverage extends StatsOverviewWidget $away_team = $data['away_team']; } - if ($arr_home) { - $median_home = self::getMedian($arr_home); - } else { - $median_home = 0; - } - if ($arr_away) { - $median_away = self::getMedian($arr_away); - } else { - $median_away = 0; - } + // if ($arr_home) { + // $median_home = self::getMedian($arr_home); + // } else { + // $median_home = 0; + // } + // if ($arr_away) { + // $median_away = self::getMedian($arr_away); + // } else { + // $median_away = 0; + // } if (isset($data['results'])) { // Log::debug($data['results']); @@ -84,12 +86,12 @@ class StatsMedianAverage extends StatsOverviewWidget return []; } - if ($total_home) { + if ($total_home && $team_id) { $value_home = number_format($summe_home / $total_home, 1); } else { $value_home = 0; } - if ($total_away) { + if ($total_away && $team_id) { $value_away = number_format($summe_away / $total_away, 1); } else { $value_away = 0;