From 13ca0d7293c5b2f88cd5f680cced7f93acccfdef Mon Sep 17 00:00:00 2001 From: salam Date: Tue, 15 Sep 2026 07:25:58 +0200 Subject: [PATCH] wip --- app/Livewire/PlayerCalculator.php | 42 ++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/app/Livewire/PlayerCalculator.php b/app/Livewire/PlayerCalculator.php index c1423565..8a28c7dc 100644 --- a/app/Livewire/PlayerCalculator.php +++ b/app/Livewire/PlayerCalculator.php @@ -16,13 +16,20 @@ class PlayerCalculator extends Component $result = []; foreach ($player as $val) { + $tmp = []; $tmp['id'] = $val->ss_player_id; - $tmp['name'] = $val->details->player_name; - $tmp['pos_ori'] = $val->details->position; + if (! isset($val->details)) { + $tmp['name'] = $val->ss_player_id; + $tmp['pos_ori'] = 'GK'; + $tmp['foot'] = 'Both'; + } else { + $tmp['name'] = $val->details->player_name; + $tmp['pos_ori'] = $val->details->position; + $tmp['foot'] = $val->details->preferred_foot; + } $tmp['pos'] = ''; $tmp['active'] = 0; - $tmp['foot'] = $val->details->preferred_foot; $tmp['tot_evt'] = $val->total_events; $tmp['tot_min'] = $val->total_min; $tmp['ave_min'] = $val->average_min; @@ -44,21 +51,26 @@ class PlayerCalculator extends Component } } - if (in_array($val->details->position, $positions_map['MIDFIELD'])) { - $tmp['area'] = 'midfield'; - $tmp['color_pos'] = 'info'; - } elseif (in_array($val->details->position, $positions_map['DEFENCE'])) { - $tmp['area'] = 'defence'; - $tmp['color_pos'] = 'success'; - } elseif (in_array($val->details->position, $positions_map['ATTACK'])) { - $tmp['area'] = 'attack'; - $tmp['color_pos'] = 'warning'; - } elseif (in_array($val->details->position, $positions_map['GOALKEEPER'])) { + if (! isset($val->details)) { $tmp['area'] = 'goalkeeper'; $tmp['color_pos'] = 'gray'; } else { - $tmp['area'] = 'defence'; - $tmp['color_pos'] = 'success'; + if (in_array($val->details->position, $positions_map['MIDFIELD'])) { + $tmp['area'] = 'midfield'; + $tmp['color_pos'] = 'info'; + } elseif (in_array($val->details->position, $positions_map['DEFENCE'])) { + $tmp['area'] = 'defence'; + $tmp['color_pos'] = 'success'; + } elseif (in_array($val->details->position, $positions_map['ATTACK'])) { + $tmp['area'] = 'attack'; + $tmp['color_pos'] = 'warning'; + } elseif (in_array($val->details->position, $positions_map['GOALKEEPER'])) { + $tmp['area'] = 'goalkeeper'; + $tmp['color_pos'] = 'gray'; + } else { + $tmp['area'] = 'defence'; + $tmp['color_pos'] = 'success'; + } } $result[] = $tmp;