diff --git a/app/Filament/Widgets/BoxesBettypeAll.php b/app/Filament/Widgets/BoxesBettypeAll.php index a057dbe0..cd878f84 100644 --- a/app/Filament/Widgets/BoxesBettypeAll.php +++ b/app/Filament/Widgets/BoxesBettypeAll.php @@ -34,8 +34,6 @@ class BoxesBettypeAll extends StatsOverviewWidget { $data = LoadEventsBoxes::load($this->filters, false); - // dd($data); - $similar_past_matches = $this->filters['similar_past_matches']; $team_position = $this->filters['team_position']; diff --git a/app/Filament/Widgets/Charts/LoadEvents/LoadEventsQueryAll.php b/app/Filament/Widgets/Charts/LoadEvents/LoadEventsQueryAll.php index 463a7ae9..40034f0d 100644 --- a/app/Filament/Widgets/Charts/LoadEvents/LoadEventsQueryAll.php +++ b/app/Filament/Widgets/Charts/LoadEvents/LoadEventsQueryAll.php @@ -26,8 +26,6 @@ class LoadEventsQueryAll $player_on_field = $filter['player_on_field'] ?? 'all'; $similar_past_matches = $filter['similar_past_matches']; $team_position = $filter['team_position']; - $home_id = $match->home_id; - $away_id = $match->away_id; $handicap_range = []; $total_range = []; @@ -103,13 +101,16 @@ class LoadEventsQueryAll return $query->where('league_id', $league_id); } }) - ->where(function ($query) use ($team_id, $home_id, $away_id, $similar_past_matches) { - if ($similar_past_matches == 'none') { - if ($team_id) { - return $query->orWhere('home_id', $team_id) - ->orWhere('away_id', '=', $team_id); - } else { - return $query->whereIn('home_id', [$home_id, $away_id])->orWhereIn('away_id', [$home_id, $away_id]); + ->where(function ($query) use ($team_id, $similar_past_matches, $team_position) { + if ($team_id && $similar_past_matches == 'none') { + switch ($team_position) { + case 'home': + return $query->where('home_id', '=', $team_id); + case 'away': + return $query->where('away_id', '=', $team_id); + default: + return $query->where('home_id', '=', $team_id) + ->orWhere('away_id', '=', $team_id); } } })