wip StatisticFixtures selection

This commit is contained in:
salam committed 2026-08-14 19:52:09 +02:00
1 parent 1dbdbcf586
commit 7d76f5bfc5
3 files changed
+12 -9

No files matched your search

@@ -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') {