This commit is contained in:
salam committed 2026-09-04 08:21:34 +02:00
1 parent f013d2563e
commit 884b468839
15 files changed
+319 -251

No files matched your search

+37 -11
View File
@@ -13,6 +13,7 @@ use Livewire\Component;
class PlayerCalculator extends Component
{
use InteractsWithPageFilters;
public $grid = [];
public function mount(array $filters)
@@ -25,8 +26,29 @@ class PlayerCalculator extends Component
array_splice($pla, $i, 0, [$v]);
$i += 2;
}
$this->grid = $pla;
// dd($this->grid);
$x = 1;
$y = 1;
foreach ($pla as $ele) {
foreach ($ele as $val) {
$tmp = [];
if (is_array($val)) {
foreach ($val as $key => $value) {
$tmp[$key] = $value;
}
$tmp['type'] = '';
} else {
$tmp['type'] = $val != 0 ? $val : '';
}
$tmp['x'] = 104 * $x;
$tmp['y'] = 104 * $y;
$this->grid[] = $tmp;
$x++;
if ($x > 10) {
$x = 1;
$y++;
}
}
}
}
public static function load(array $filters)
@@ -58,7 +80,7 @@ class PlayerCalculator extends Component
foreach ($player as $val) {
if ($val->details) {
$player_id = $val->ss_player_id;
if (!isset($arr[$player_id])) {
if (! isset($arr[$player_id])) {
$arr[$player_id]['player_name'] = $val->details->player_name;
$arr[$player_id]['events_played_home'] = $val->events_played_home;
$arr[$player_id]['events_played_away'] = $val->events_played_away;
@@ -76,7 +98,6 @@ class PlayerCalculator extends Component
}
}
$result = [];
foreach ($arr as $player_id => $val) {
@@ -95,27 +116,31 @@ class PlayerCalculator extends Component
break;
}
$colorlevel = round($matches->count() / 3);
if (in_array($val['player_position'], $positions_map['MIDFIELD'])) {
$position = 'MIDFIELD';
} else if (in_array($val['player_position'], $positions_map['DEFENCE'])) {
$position_color = 'info';
} elseif (in_array($val['player_position'], $positions_map['DEFENCE'])) {
$position = 'DEFENCE';
} else if (in_array($val['player_position'], $positions_map['ATTACK'])) {
$position_color = 'success';
} elseif (in_array($val['player_position'], $positions_map['ATTACK'])) {
$position = 'ATTACK';
} else if (in_array($val['player_position'], $positions_map['GOALKEEPER'])) {
$position_color = 'warning';
} elseif (in_array($val['player_position'], $positions_map['GOALKEEPER'])) {
$position = 'GOALKEEPER';
$position_color = 'gray';
} else {
$position = 'NO SPECIFIC POSITION';
$position_color = '';
}
$name = $val['player_name'];
$preferred_foot = $val['preferred_foot'] ?? '-';
$everage_minutes = round($minues_played / $events_played) . ' min';
$everage_minutes = round($minues_played / $events_played).' min';
if ($colorlevel > 1 && $events_played < $colorlevel) {
$color = 'danger';
} else if ($events_played < $colorlevel * 2) {
} elseif ($events_played < $colorlevel * 2) {
$color = 'info';
} else {
$color = 'success';
@@ -125,8 +150,9 @@ class PlayerCalculator extends Component
'player_id' => $player_id,
'name' => $name,
'position' => $position,
'position_color' => $position_color,
'color' => $color,
'info' => 'Ev ' . $events_played . ', ' . $preferred_foot . ', ' . $everage_minutes,
'info' => 'Ev '.$events_played.', '.$preferred_foot.', '.$everage_minutes,
];
}