wip statistic events quasi

This commit is contained in:
salam committed 2026-04-30 13:57:38 +02:00
1 parent 897a327709
commit 58b9abbd32
6 files changed
+106 -25

No files matched your search

+36 -5
View File
@@ -35,11 +35,11 @@ class LoadEvents
*/
switch ($filter['team_position']) {
case 'home':
$res = StatisticFixtures::where('league_id', $league_id)->where('home_id', '=', $team_id)->first();
$res = StatisticFixtures::where('league_id', $league_id)->where('home_id', $team_id)->first();
break;
case 'away':
$res = StatisticFixtures::where('league_id', $league_id)->where('away_id', '=', $team_id)->first();
$res = StatisticFixtures::where('league_id', $league_id)->where('away_id', $team_id)->first();
break;
default:
@@ -59,16 +59,40 @@ class LoadEvents
$exp_away_from = $exp_away - $accuracy;
$exp_away_to = $exp_away + $accuracy;
// dd($team_id, $exp_home, $exp_away);
// "endDate"
// "startDate"
$start = $filter['startDate'] ?? 0;
$end = $filter['endDate'] ?? 0;
/**
* STATTISTIC DATA
*/
switch ($filter['team_position']) {
case 'home':
$res = StatistikoEvent::where('league_id', $league_id)->where('home_id', '=', $team_id)->whereBetween('expgoalhome_value', [$exp_home_from, $exp_home_to])->get();
$res = StatistikoEvent::where('league_id', $league_id)
->where('home_id', '=', $team_id)
->whereBetween('exp_home', [$exp_home_from, $exp_home_to])
->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 'away':
$res = StatistikoEvent::where('league_id', $league_id)->where('away_id', '=', $team_id)->whereBetween('expgoalsaway_value', [$exp_away_from, $exp_away_to])->get();
$res = StatistikoEvent::where('league_id', $league_id)
->where('away_id', '=', $team_id)
->whereBetween('exp_away', [$exp_away_from, $exp_away_to])
->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:
@@ -77,7 +101,12 @@ class LoadEvents
$query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
})
->where(function ($query) use ($exp_home_from, $exp_home_to, $exp_away_from, $exp_away_to) {
$query->whereBetween('expgoalhome_value', [$exp_home_from, $exp_home_to])->orWhereBetween('expgoalsaway_value', [$exp_away_from, $exp_away_to]);
$query->whereBetween('exp_home', [$exp_home_from, $exp_home_to])->orWhereBetween('exp_away', [$exp_away_from, $exp_away_to]);
})
->when($start, function ($query) use ($start) {
return $query->where('starttime', '>=', $start);
})->when($end, function ($query) use ($end) {
return $query->where('starttime', '<=', $end);
})->get();
break;
}
@@ -213,6 +242,8 @@ class LoadEvents
[
'label' => ucfirst($team_position),
'data' => $datasets,
'fill' => true,
'tension' => 0.5,
'borderColor' => '#36A2EB',
],
],