wip
This commit is contained in:
1 parent
884b468839
commit
d46fa5c51c
13 files changed
+331
-261
No files matched your search
@@ -4,7 +4,6 @@ namespace App\Livewire;
|
||||
|
||||
use App\Filament\Pages\Selections\Helper\GetSeason;
|
||||
use App\Filament\Pages\Selections\LoadPositions;
|
||||
use App\Livewire\Mapper\LoadGridPositions;
|
||||
use App\Models\SofaScorePlayerPerSeason;
|
||||
use App\Models\StatistikoEvent;
|
||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||
@@ -14,41 +13,11 @@ class PlayerCalculator extends Component
|
||||
{
|
||||
use InteractsWithPageFilters;
|
||||
|
||||
public $grid = [];
|
||||
public $players = [];
|
||||
|
||||
public function mount(array $filters)
|
||||
{
|
||||
$pos = array_chunk(LoadGridPositions::load(), 5);
|
||||
$pla = array_chunk(self::load($filters), 5);
|
||||
|
||||
$i = 1;
|
||||
while ($v = array_shift($pos)) {
|
||||
array_splice($pla, $i, 0, [$v]);
|
||||
$i += 2;
|
||||
}
|
||||
$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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->players = self::load($filters);
|
||||
}
|
||||
|
||||
public static function load(array $filters)
|
||||
@@ -137,7 +106,7 @@ class PlayerCalculator extends Component
|
||||
|
||||
$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';
|
||||
} elseif ($events_played < $colorlevel * 2) {
|
||||
@@ -148,20 +117,14 @@ class PlayerCalculator extends Component
|
||||
|
||||
$result[] = [
|
||||
'player_id' => $player_id,
|
||||
'name' => $name,
|
||||
'player_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,
|
||||
];
|
||||
}
|
||||
|
||||
$maxlength = 35;
|
||||
$len = count($result);
|
||||
if ($len < $maxlength) {
|
||||
$result += array_fill($len, $maxlength - $len, [0, 0, 0, 0, 0, 0, 0]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user