diff --git a/app/Filament/Widgets/Data/LoadEvents/LoadEventsAverages.php b/app/Filament/Widgets/Data/LoadEvents/LoadEventsAverages.php index 74f797c8..545b26dd 100644 --- a/app/Filament/Widgets/Data/LoadEvents/LoadEventsAverages.php +++ b/app/Filament/Widgets/Data/LoadEvents/LoadEventsAverages.php @@ -18,21 +18,22 @@ class LoadEventsAverages $statistic_type = $filter['statistic_type'] ?? 'gls'; - $res = SofaScoreTournament::with('sofascore_category')->where('tournament_id', $tournament_id)->first(); + $season = $filter['season'] ?? 0; - $country_id = $res->sofascore_category->country_id; - $season_mode = Country::where('id', $country_id)->value('season_mode'); - if ($season_mode == 'fullyear') { - $season = date('Y'); - } else { - $season = date('y') - 1 . '/' . date('Y'); - } + $season_or_date = $filter['season_or_date'] ?? 'season'; + + if ($season_or_date != 'season') + $season = 0; $res = StatistikoEvent::where('league_id', $tournament_id) - // ->where('season', $season) + ->when($season, function ($query) use ($season) { + return $query->whereIn('season', $season); + }) ->orderBy('starttime', 'ASC') ->get(); + // dd($res); + if ($res) { $team_home = [];