From d39a3a1dc2c469d93ba66eb9496d199f9359bb78 Mon Sep 17 00:00:00 2001 From: salam Date: Thu, 21 May 2026 18:33:20 +0200 Subject: [PATCH] wip --- app/Actions/Statistics/LoadEventsAspGoal.php | 99 +++++++++++++------- 1 file changed, 64 insertions(+), 35 deletions(-) diff --git a/app/Actions/Statistics/LoadEventsAspGoal.php b/app/Actions/Statistics/LoadEventsAspGoal.php index a5f03b73..43451532 100644 --- a/app/Actions/Statistics/LoadEventsAspGoal.php +++ b/app/Actions/Statistics/LoadEventsAspGoal.php @@ -4,8 +4,6 @@ namespace App\Actions\Statistics; use App\Models\StatisticFixtures; use App\Models\StatistikoEvent; -use Illuminate\Support\Facades\DB; -use Illuminate\Support\Facades\Log; class LoadEventsAspGoal { @@ -64,16 +62,53 @@ class LoadEventsAspGoal switch ($similar_past_matches) { case 'league': - $team_id = 0; + $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) { + return $query->where('league_id', $league_id); + })->when($handicap_range, function ($query) use ($handicap_range) { + return $query->whereBetween('exp_handicap', $handicap_range); + })->when($total_range, function ($query) use ($total_range) { + return $query->whereBetween('exp_total', $total_range); + })->when($start, function ($query) use ($start) { + return $query->where('starttime', '>=', $start); + })->when($end, function ($query) use ($end) { + return $query->where('starttime', '<=', $end); + }) + ->get(); break; case 'all': - $league_id = 0; - $team_id = 0; + $res = StatistikoEvent::when($handicap_range, function ($query) use ($handicap_range) { + return $query->whereBetween('exp_handicap', $handicap_range); + })->when($total_range, function ($query) use ($total_range) { + return $query->whereBetween('exp_total', $total_range); + })->when($start, function ($query) use ($start) { + return $query->where('starttime', '>=', $start); + })->when($end, function ($query) use ($end) { + return $query->where('starttime', '<=', $end); + }) + ->get(); + break; default: - // none - $handicap_range = 0; - $total_range = 0; + /** + * STATISTIC DATA + */ + $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) { + return $query->where('league_id', $league_id); + })->when($team_id, function ($query) use ($team_id, $team_position) { + 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); + } + })->when($start, function ($query) use ($start) { + return $query->where('starttime', '>=', $start); + })->when($end, function ($query) use ($end) { + return $query->where('starttime', '<=', $end); + }) + ->get(); break; } @@ -81,33 +116,27 @@ class LoadEventsAspGoal /** * STATISTIC DATA */ - DB::connection()->enableQueryLog(); - - $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) { - return $query->where('league_id', $league_id); - })->when($team_id, function ($query) use ($team_id, $team_position) { - 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); - } - })->when($handicap_range, function ($query) use ($handicap_range) { - return $query->whereBetween('exp_handicap', $handicap_range); - })->when($total_range, function ($query) use ($total_range) { - return $query->whereBetween('exp_total', $total_range); - })->when($start, function ($query) use ($start) { - return $query->where('starttime', '>=', $start); - })->when($end, function ($query) use ($end) { - return $query->where('starttime', '<=', $end); - }) - ->get(); - - DB::listen(function ($res) { - Log::info($res->sql, $res->bindings); - }); + // $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) { + // return $query->where('league_id', $league_id); + // })->when($team_id, function ($query) use ($team_id, $team_position) { + // 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); + // } + // })->when($handicap_range, function ($query) use ($handicap_range) { + // return $query->whereBetween('exp_handicap', $handicap_range); + // })->when($total_range, function ($query) use ($total_range) { + // return $query->whereBetween('exp_total', $total_range); + // })->when($start, function ($query) use ($start) { + // return $query->where('starttime', '>=', $start); + // })->when($end, function ($query) use ($end) { + // return $query->where('starttime', '<=', $end); + // }) + // ->get(); $datasets = []; $labels = [];