From 7d76f5bfc5af3b33d812ac7a009db313280da7d8 Mon Sep 17 00:00:00 2001 From: salam Date: Fri, 14 Aug 2026 19:52:09 +0200 Subject: [PATCH] wip StatisticFixtures selection --- app/Filament/Widgets/Data/LoadEvents.php | 5 +++-- .../Widgets/Data/LoadEvents/LoadEventsQuery.php | 12 ++++++++---- .../Widgets/Data/LoadEvents/LoadExpectations.php | 4 +--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/Filament/Widgets/Data/LoadEvents.php b/app/Filament/Widgets/Data/LoadEvents.php index fa329a62..ac5b2cad 100644 --- a/app/Filament/Widgets/Data/LoadEvents.php +++ b/app/Filament/Widgets/Data/LoadEvents.php @@ -121,10 +121,11 @@ class LoadEvents } } + $match = StatisticFixtures::where('id', $match_id)->first(); /** * STATTISTIC DATA */ - $res = LoadEventsQuery::load($filter, $matches_played, $handicap_range, $total_range); + $res = LoadEventsQuery::load($filter, $matches_played, $handicap_range, $total_range, $match); $dataset_home = []; $dataset_away = []; @@ -143,7 +144,7 @@ class LoadEvents return []; } - $expectations = LoadExpectations::load($res['all'], $match_id, $statistic_type); + $expectations = LoadExpectations::load($res['all'], $match, $statistic_type); foreach ($res[$team_position] as $value) { diff --git a/app/Filament/Widgets/Data/LoadEvents/LoadEventsQuery.php b/app/Filament/Widgets/Data/LoadEvents/LoadEventsQuery.php index af8f7c06..7fc3dc5a 100644 --- a/app/Filament/Widgets/Data/LoadEvents/LoadEventsQuery.php +++ b/app/Filament/Widgets/Data/LoadEvents/LoadEventsQuery.php @@ -6,7 +6,7 @@ use App\Models\StatistikoEvent; class LoadEventsQuery { - public static function load(array $filter, array $matches_played, array $handicap_range, array $total_range) + public static function load(array $filter, array $matches_played, array $handicap_range, array $total_range, object $match) { $league_id = (int) $filter['league_id'] ?? 0; $team_id = (int) $filter['team_id'] ?? 0; @@ -16,6 +16,8 @@ class LoadEventsQuery $player_on_field = $filter['player_on_field'] ?? 'all'; $similar_past_matches = $filter['similar_past_matches']; $statistic_type = $filter['statistic_type'] ?? 'gls'; + $home_id = $match->home_id; + $away_id = $match->away_id; if ($statistic_type == 'none') { $statistic_type = 'gls'; @@ -32,10 +34,12 @@ class LoadEventsQuery return $query->where('league_id', $league_id); } }) - ->where(function ($query) use ($team_id, $similar_past_matches) { + ->where(function ($query) use ($home_id, $away_id, $similar_past_matches) { if ($similar_past_matches == 'none') { - return $query->where('home_id', '=', $team_id) - ->orWhere('away_id', '=', $team_id); + return $query->where('home_id', '=', $home_id) + ->orWhere('away_id', '=', $home_id) + ->orWhere('home_id', '=', $away_id) + ->orWhere('away_id', '=', $away_id); } })->when($matches_played, function ($query) use ($matches_played, $player_on_field) { if ($player_on_field == 'notplayed') { diff --git a/app/Filament/Widgets/Data/LoadEvents/LoadExpectations.php b/app/Filament/Widgets/Data/LoadEvents/LoadExpectations.php index 188cb8ae..c11519ae 100644 --- a/app/Filament/Widgets/Data/LoadEvents/LoadExpectations.php +++ b/app/Filament/Widgets/Data/LoadEvents/LoadExpectations.php @@ -7,10 +7,8 @@ use App\Models\StatistikoConfig; class LoadExpectations { - public static function load(array $data, int $match_id, string $statistic_type) + public static function load(array $data, object $match, string $statistic_type) { - $match = StatisticFixtures::where('id', $match_id)->first(); - $home_id = $match->home_id; $away_id = $match->away_id;