add 2 parts for claculation pp wip

This commit is contained in:
salam committed 2026-10-31 19:22:16 +01:00
1 parent 6d2f4c1052
commit ad45880506
19 files changed
+1403 -1049

No files matched your search

+84
View File
@@ -0,0 +1,84 @@
<?php
namespace App\Traits\PlayerProps;
use App\Filament\Pages\Selections\LoadPositions;
use App\Models\SofaScoreRosa;
trait SyncData
{
public function syncData(int $team_id)
{
if ($team_id) {
$this->players = [];
$positions_map = LoadPositions::load();
$players = $this->loadPlayerAll();
foreach ($players as $val) {
$tmp = [];
$tmp['id'] = $val['ss_player_id'];
$tmp['name'] = $val['player_name'];
$tmp['pos_ori'] = $val['position'];
$tmp['foot'] = $val['preferred_foot'];
$tmp['pos'] = '';
$tmp['active'] = 0;
$tmp['tot_evt'] = $val['total_events'];
$tmp['tot_min'] = $val['total_min'];
$tmp['ave_min'] = $val['average_min'];
$tmp['gls'] = $val['goals'];
$tmp['fls'] = $val['fouls'];
$tmp['ofs'] = $val['offsides'];
$tmp['crd'] = $val['cards'];
$tmp['snt'] = $val['shots_on_target'];
$tmp['tsh'] = $val['shots_off_target'];
$tmp['wfl'] = $val['was_fouled'];
$level = round($val['total_events'] / 3);
if ($val['total_events']) {
if ($level > 1 && $val['total_events'] < $level) {
$tmp['color_evt'] = 'danger';
} elseif ($val['total_events'] < $level * 2) {
$tmp['color_evt'] = 'info';
} else {
$tmp['color_evt'] = 'success';
}
}
if (in_array($val['position'], $positions_map['MIDFIELD'])) {
$tmp['area'] = 'midfield';
$tmp['color_pos'] = 'info';
$tmp['order'] = 2;
} elseif (in_array($val['position'], $positions_map['DEFENCE'])) {
$tmp['area'] = 'defence';
$tmp['color_pos'] = 'success';
$tmp['order'] = 1;
} elseif (in_array($val['position'], $positions_map['ATTACK'])) {
$tmp['area'] = 'attack';
$tmp['color_pos'] = 'warning';
$tmp['order'] = 3;
} elseif (in_array($val['position'], $positions_map['GOALKEEPER'])) {
$tmp['area'] = 'goalkeeper';
$tmp['color_pos'] = 'gray';
$tmp['order'] = 4;
} else {
$tmp['area'] = 'defence';
$tmp['color_pos'] = 'success';
$tmp['order'] = 5;
}
$this->players[] = $tmp;
}
$this->team_name = SofaScoreRosa::where('ss_team_id', $this->team_id)->value('ss_team_name');
$this->loadPlacement();
} else {
$this->team_name = '';
$this->clearResultTable();
$this->players = [];
}
}
}