This commit is contained in:
salam committed 2026-05-21 18:33:20 +02:00
1 parent e7936de68d
commit d39a3a1dc2
1 file changed
+64 -35
+64 -35
View File
@@ -4,8 +4,6 @@ namespace App\Actions\Statistics;
use App\Models\StatisticFixtures; use App\Models\StatisticFixtures;
use App\Models\StatistikoEvent; use App\Models\StatistikoEvent;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class LoadEventsAspGoal class LoadEventsAspGoal
{ {
@@ -64,16 +62,53 @@ class LoadEventsAspGoal
switch ($similar_past_matches) { switch ($similar_past_matches) {
case 'league': 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; break;
case 'all': case 'all':
$league_id = 0; $res = StatistikoEvent::when($handicap_range, function ($query) use ($handicap_range) {
$team_id = 0; 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; break;
default: default:
// none /**
$handicap_range = 0; * STATISTIC DATA
$total_range = 0; */
$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; break;
} }
@@ -81,33 +116,27 @@ class LoadEventsAspGoal
/** /**
* STATISTIC DATA * STATISTIC DATA
*/ */
DB::connection()->enableQueryLog(); // $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
// return $query->where('league_id', $league_id);
$res = StatistikoEvent::when($league_id, function ($query) use ($league_id) { // })->when($team_id, function ($query) use ($team_id, $team_position) {
return $query->where('league_id', $league_id); // switch ($team_position) {
})->when($team_id, function ($query) use ($team_id, $team_position) { // case 'home':
switch ($team_position) { // return $query->where('home_id', $team_id);
case 'home': // case 'away':
return $query->where('home_id', $team_id); // return $query->where('away_id', $team_id);
case 'away': // default:
return $query->where('away_id', $team_id); // return $query->where('home_id', '=', $team_id)->orWhere('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($handicap_range, function ($query) use ($handicap_range) { // })->when($total_range, function ($query) use ($total_range) {
return $query->whereBetween('exp_handicap', $handicap_range); // return $query->whereBetween('exp_total', $total_range);
})->when($total_range, function ($query) use ($total_range) { // })->when($start, function ($query) use ($start) {
return $query->whereBetween('exp_total', $total_range); // return $query->where('starttime', '>=', $start);
})->when($start, function ($query) use ($start) { // })->when($end, function ($query) use ($end) {
return $query->where('starttime', '>=', $start); // return $query->where('starttime', '<=', $end);
})->when($end, function ($query) use ($end) { // })
return $query->where('starttime', '<=', $end); // ->get();
})
->get();
DB::listen(function ($res) {
Log::info($res->sql, $res->bindings);
});
$datasets = []; $datasets = [];
$labels = []; $labels = [];