From 2526c9001ea44983589393dc164d4ebe3bca4411 Mon Sep 17 00:00:00 2001 From: salam Date: Fri, 11 Sep 2026 10:56:48 +0200 Subject: [PATCH] wip --- app/Traits/UpdateHelper.php | 89 +++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/app/Traits/UpdateHelper.php b/app/Traits/UpdateHelper.php index 7452e533..df389fd3 100644 --- a/app/Traits/UpdateHelper.php +++ b/app/Traits/UpdateHelper.php @@ -128,8 +128,6 @@ trait UpdateHelper $collection = []; foreach ($res as $val) { - dd($val); - $ss_player_id = (int) $val->ss_player_id; $activeteam_id = (int) $val->activeteam_id; $minutes_played = (int) $val->minutes_played; @@ -138,53 +136,56 @@ trait UpdateHelper $home_id = (int) $val->event->home_id; $away_id = (int) $val->event->away_id; - if (! isset($collection[$season][$ss_player_id])) { - $this->array_template($collection, $ss_player_id, $season); - } - if (! isset($collection['total'][$ss_player_id])) { - $this->array_template($collection, $ss_player_id, 'total'); - } + if ($season) { - if ($minutes_played > 0) { - if ($activeteam_id == $home_id) { - $collection[$season][$ss_player_id]['events_played_home'] += 1; - $collection[$season][$ss_player_id]['minutes_played_home'] += $minutes_played; - $collection['total'][$ss_player_id]['events_played_home'] += 1; - $collection['total'][$ss_player_id]['minutes_played_home'] += $minutes_played; - } elseif ($activeteam_id == $away_id) { - $collection[$season][$ss_player_id]['events_played_away'] += 1; - $collection[$season][$ss_player_id]['minutes_played_away'] += $minutes_played; - $collection['total'][$ss_player_id]['minutes_played_away'] += 1; - $collection['total'][$ss_player_id]['minutes_played_away'] += $minutes_played; + if (! isset($collection[$season][$ss_player_id])) { + $this->array_template($collection, $ss_player_id, $season); + } + if (! isset($collection['total'][$ss_player_id])) { + $this->array_template($collection, $ss_player_id, 'total'); } - $cards = $val->card_yellow + $val->card_yellowred + $val->card_red; + if ($minutes_played > 0) { + if ($activeteam_id == $home_id) { + $collection[$season][$ss_player_id]['events_played_home'] += 1; + $collection[$season][$ss_player_id]['minutes_played_home'] += $minutes_played; + $collection['total'][$ss_player_id]['events_played_home'] += 1; + $collection['total'][$ss_player_id]['minutes_played_home'] += $minutes_played; + } elseif ($activeteam_id == $away_id) { + $collection[$season][$ss_player_id]['events_played_away'] += 1; + $collection[$season][$ss_player_id]['minutes_played_away'] += $minutes_played; + $collection['total'][$ss_player_id]['minutes_played_away'] += 1; + $collection['total'][$ss_player_id]['minutes_played_away'] += $minutes_played; + } - $collection[$season][$ss_player_id]['ss_player_id'] = $ss_player_id; - $collection[$season][$ss_player_id]['ss_team_id'] = $ss_team_id; - $collection[$season][$ss_player_id]['season'] = $season; - $collection[$season][$ss_player_id]['total_events']++; - $collection[$season][$ss_player_id]['total_min'] += $minutes_played; - $collection[$season][$ss_player_id]['average_min'] = round($collection[$season][$ss_player_id]['total_min'] / $collection[$season][$ss_player_id]['total_events']); - $collection[$season][$ss_player_id]['goals'] += $val->goals; - $collection[$season][$ss_player_id]['fouls'] += $val->fouls; - $collection[$season][$ss_player_id]['cards'] += $cards; - $collection[$season][$ss_player_id]['offsides'] += $val->offsides; - $collection[$season][$ss_player_id]['shots_on_target'] += $val->shots_on_target; - $collection[$season][$ss_player_id]['shots_off_target'] += $val->shots_off_target; + $cards = $val->card_yellow + $val->card_yellowred + $val->card_red; - $collection['total'][$ss_player_id]['ss_player_id'] = $ss_player_id; - $collection['total'][$ss_player_id]['ss_team_id'] = $ss_team_id; - $collection['total'][$ss_player_id]['season'] = 'total'; - $collection['total'][$ss_player_id]['total_events']++; - $collection['total'][$ss_player_id]['total_min'] += $minutes_played; - $collection['total'][$ss_player_id]['average_min'] = round($collection['total'][$ss_player_id]['total_min'] / $collection['total'][$ss_player_id]['total_events']); - $collection['total'][$ss_player_id]['goals'] += $val->goals; - $collection['total'][$ss_player_id]['fouls'] += $val->fouls; - $collection['total'][$ss_player_id]['cards'] += $cards; - $collection['total'][$ss_player_id]['offsides'] += $val->offsides; - $collection['total'][$ss_player_id]['shots_on_target'] += $val->shots_on_target; - $collection['total'][$ss_player_id]['shots_off_target'] += $val->shots_off_target; + $collection[$season][$ss_player_id]['ss_player_id'] = $ss_player_id; + $collection[$season][$ss_player_id]['ss_team_id'] = $ss_team_id; + $collection[$season][$ss_player_id]['season'] = $season; + $collection[$season][$ss_player_id]['total_events']++; + $collection[$season][$ss_player_id]['total_min'] += $minutes_played; + $collection[$season][$ss_player_id]['average_min'] = round($collection[$season][$ss_player_id]['total_min'] / $collection[$season][$ss_player_id]['total_events']); + $collection[$season][$ss_player_id]['goals'] += $val->goals; + $collection[$season][$ss_player_id]['fouls'] += $val->fouls; + $collection[$season][$ss_player_id]['cards'] += $cards; + $collection[$season][$ss_player_id]['offsides'] += $val->offsides; + $collection[$season][$ss_player_id]['shots_on_target'] += $val->shots_on_target; + $collection[$season][$ss_player_id]['shots_off_target'] += $val->shots_off_target; + + $collection['total'][$ss_player_id]['ss_player_id'] = $ss_player_id; + $collection['total'][$ss_player_id]['ss_team_id'] = $ss_team_id; + $collection['total'][$ss_player_id]['season'] = 'total'; + $collection['total'][$ss_player_id]['total_events']++; + $collection['total'][$ss_player_id]['total_min'] += $minutes_played; + $collection['total'][$ss_player_id]['average_min'] = round($collection['total'][$ss_player_id]['total_min'] / $collection['total'][$ss_player_id]['total_events']); + $collection['total'][$ss_player_id]['goals'] += $val->goals; + $collection['total'][$ss_player_id]['fouls'] += $val->fouls; + $collection['total'][$ss_player_id]['cards'] += $cards; + $collection['total'][$ss_player_id]['offsides'] += $val->offsides; + $collection['total'][$ss_player_id]['shots_on_target'] += $val->shots_on_target; + $collection['total'][$ss_player_id]['shots_off_target'] += $val->shots_off_target; + } } }