This commit is contained in:
salam committed 2026-04-30 10:47:47 +02:00
1 parent 3351795115
commit 7fa1dd9d20
2 files changed
+242 -192

No files matched your search

+41 -4
View File
@@ -2,6 +2,7 @@
namespace App\Actions\Statistics;
use App\Models\StatisticFixtures;
use App\Models\StatistikoEvent;
class LoadEvents
@@ -10,6 +11,7 @@ class LoadEvents
public static function load($filter)
{
// dd($filter);
if (self::$last_query) {
return self::$last_query;
@@ -19,8 +21,6 @@ class LoadEvents
$team_id = (int) $filter['team_id'] ?? 0;
$team_position = $filter['team_position'];
if (! $league_id) {
return [];
}
@@ -28,19 +28,56 @@ class LoadEvents
return [];
}
$team_position = $filter['team_position'];
/**
* ACCURACY DATA
*/
switch ($filter['team_position']) {
case 'home':
$res = StatistikoEvent::where('league_id', $league_id)->where('home_id', '=', $team_id)->get();
$res = StatisticFixtures::where('league_id', $league_id)->where('home_id', '=', $team_id)->first();
break;
case 'away':
$res = StatistikoEvent::where('league_id', $league_id)->where('away_id', '=', $team_id)->get();
$res = StatisticFixtures::where('league_id', $league_id)->where('away_id', '=', $team_id)->first();
break;
default:
$res = StatisticFixtures::where('league_id', $league_id)
->where(function ($query) use ($team_id) {
$query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
})->first();
break;
}
$accuracy = (float) $filter['accuracy'];
$exp_home = $res['exp_home'] ?? 0;
$exp_home_from = $exp_home - $accuracy;
$exp_home_to = $exp_home + $accuracy;
$exp_away = $res['exp_away'] ?? 0;
$exp_away_from = $exp_away - $accuracy;
$exp_away_to = $exp_away + $accuracy;
/**
* 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();
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();
break;
default:
$res = StatistikoEvent::where('league_id', $league_id)
->where(function ($query) use ($team_id) {
$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]);
})->get();
break;
}