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

+3 -2
View File
@@ -121,10 +121,11 @@ class LoadEvents
} }
} }
$match = StatisticFixtures::where('id', $match_id)->first();
/** /**
* STATTISTIC DATA * STATTISTIC DATA
*/ */
$res = LoadEventsQuery::load($filter, $matches_played, $handicap_range, $total_range); $res = LoadEventsQuery::load($filter, $matches_played, $handicap_range, $total_range, $match);
$dataset_home = []; $dataset_home = [];
$dataset_away = []; $dataset_away = [];
@@ -143,7 +144,7 @@ class LoadEvents
return []; return [];
} }
$expectations = LoadExpectations::load($res['all'], $match_id, $statistic_type); $expectations = LoadExpectations::load($res['all'], $match, $statistic_type);
foreach ($res[$team_position] as $value) { foreach ($res[$team_position] as $value) {
@@ -6,7 +6,7 @@ use App\Models\StatistikoEvent;
class LoadEventsQuery 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; $league_id = (int) $filter['league_id'] ?? 0;
$team_id = (int) $filter['team_id'] ?? 0; $team_id = (int) $filter['team_id'] ?? 0;
@@ -16,6 +16,8 @@ class LoadEventsQuery
$player_on_field = $filter['player_on_field'] ?? 'all'; $player_on_field = $filter['player_on_field'] ?? 'all';
$similar_past_matches = $filter['similar_past_matches']; $similar_past_matches = $filter['similar_past_matches'];
$statistic_type = $filter['statistic_type'] ?? 'gls'; $statistic_type = $filter['statistic_type'] ?? 'gls';
$home_id = $match->home_id;
$away_id = $match->away_id;
if ($statistic_type == 'none') { if ($statistic_type == 'none') {
$statistic_type = 'gls'; $statistic_type = 'gls';
@@ -32,10 +34,12 @@ class LoadEventsQuery
return $query->where('league_id', $league_id); 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') { if ($similar_past_matches == 'none') {
return $query->where('home_id', '=', $team_id) return $query->where('home_id', '=', $home_id)
->orWhere('away_id', '=', $team_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) { })->when($matches_played, function ($query) use ($matches_played, $player_on_field) {
if ($player_on_field == 'notplayed') { if ($player_on_field == 'notplayed') {
@@ -7,10 +7,8 @@ use App\Models\StatistikoConfig;
class LoadExpectations class LoadExpectations
{ {
public static function load(array $data, int $match_id, string $statistic_type) public static function load(array $data, object $match, string $statistic_type)
{ {
$match = StatisticFixtures::where('id', $match_id)->first();
$home_id = $match->home_id; $home_id = $match->home_id;
$away_id = $match->away_id; $away_id = $match->away_id;