This commit is contained in:
salam committed 2026-08-14 20:31:07 +02:00
1 parent 377478d9e8
commit 8a5b03eec4
3 files changed
+97 -93

No files matched your search

+3 -52
View File
@@ -18,10 +18,8 @@ class LoadEvents
$match_id = (int) $filter['match_id'] ?? 0;
$team_id = (int) $filter['team_id'] ?? 0;
$season_or_date = $filter['season_or_date'] ?? 'season';
$ss_player_id = (int) $filter['ss_player_id'] ?? 0;
$statistic_type = $filter['statistic_type'] ?? 'gls';
$team_position = $filter['team_position'];
$player_on_field = $filter['player_on_field'] ?? 'all';
$accuracy = (float) $filter['accuracy'] ?? 0.5;
$similar_past_matches = $filter['similar_past_matches'];
@@ -76,56 +74,12 @@ class LoadEvents
$away_team = 'Against';
}
/**
* IF WITH PLAYER
*/
$matches_played = [];
$description = '';
if ($ss_player_id) {
$matches_season = StatistikoEvent::where(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);
}
})->pluck('match_id')->toArray();
$matches_played = StatistikoPlayer::query()
->whereIn('match_id', $matches_season)
->where('ss_player_id', $ss_player_id)
->when($player_on_field, function ($query) use ($player_on_field) {
// 'all' => 'All',
// 'lineup' => 'Lineup',
// 'substituted' => 'Substituted',
// 'notplayed' => 'Not Played',
switch ($player_on_field) {
case 'all':
return $query->where('minutes_played', '>', 0);
case 'lineup':
return $query->where('lineup', 'T')->where('minutes_played', '>', 0);
case 'substituted':
return $query->where('lineup', 'P')->where('minutes_played', '>', 0);
default:
return $query->where('minutes_played', '>', 0);
}
})
->pluck('match_id')->toArray();
if (! $matches_played) {
$matches_played[] = -1;
}
}
$match = StatisticFixtures::where('id', $match_id)->first();
/**
* STATTISTIC DATA
*/
$res = LoadEventsQuery::load($filter, $matches_played, $handicap_range, $total_range, $match);
$res = LoadEventsQuery::load($filter, $handicap_range, $total_range, $match);
$dataset_home = [];
$dataset_away = [];
@@ -137,11 +91,8 @@ class LoadEvents
$events = [];
$results = ['w' => 0, 'd' => 0, 'l' => 0, 'w2' => 0, 'l2' => 0];
if (!\in_array($team_position, ['home', 'away']))
if (!$team_id || !\in_array($team_position, ['home', 'away'])) {
$team_position = 'all';
if (!isset($res[$team_position])) {
return [];
}
$expectations = LoadExpectations::load($res['all'], $match, $statistic_type);