This commit is contained in:
salam committed 2026-09-15 11:26:16 +02:00
1 parent 085dc78e26
commit 958944f21c
6 files changed
+30 -16

No files matched your search

+10 -8
View File
@@ -11,7 +11,7 @@ class ImportDetails
{ {
public static function run(string $filePath): void public static function run(string $filePath): void
{ {
StatistikoDetail::query()->update(['last_import' => 'out']); StatistikoDetail::query()->update(['last_import' => 'no']);
SimpleExcelReader::create(storage_path('app/public/'.$filePath)) SimpleExcelReader::create(storage_path('app/public/'.$filePath))
->getRows() ->getRows()
@@ -20,12 +20,14 @@ class ImportDetails
$collection = []; $collection = [];
foreach ($chunk as $row) { foreach ($chunk as $row) {
$row['is_active'] = 1; if ($row['player_name'] != '') {
$row['last_import'] = 'in'; $row['is_active'] = 1;
$row['birthdate'] = isset($row['birthday']) ? Carbon::parse($row['birthday'])->format('Y-m-d') : ''; $row['last_import'] = 'yes';
unset($row['birthday']); $row['birthdate'] = isset($row['birthday']) ? Carbon::parse($row['birthday'])->format('Y-m-d') : '';
$row['last_update'] = Carbon::parse($row['last_update'])->format('Y-m-d H:i:s'); unset($row['birthday']);
$collection[] = $row; $row['last_update'] = Carbon::parse($row['last_update'])->format('Y-m-d H:i:s');
$collection[] = $row;
}
} }
StatistikoDetail::upsert( StatistikoDetail::upsert(
@@ -48,6 +50,6 @@ class ImportDetails
]); ]);
}); });
StatistikoDetail::where('last_import', 'out')->update(['is_active' => 0, 'ss_team_id' => 0]); StatistikoDetail::where('last_import', 'no')->update(['is_active' => 0, 'ss_team_id' => 0]);
} }
} }
+4 -1
View File
@@ -70,6 +70,7 @@ class PlayerPropsDrop extends Widget
public function matchUpdate(int $match_id) public function matchUpdate(int $match_id)
{ {
$this->match_id = $match_id; $this->match_id = $match_id;
$this->loadPlacement();
} }
#[On('team-update')] #[On('team-update')]
@@ -159,7 +160,7 @@ class PlayerPropsDrop extends Widget
} }
} }
} }
$this->dispatch('update-players', players: $this->players); $this->calculateAspg();
} }
public function storePlacement() public function storePlacement()
@@ -325,6 +326,8 @@ class PlayerPropsDrop extends Widget
$this->players[$k]['crd'] = ''; $this->players[$k]['crd'] = '';
} }
$this->dispatch('update-players', players: $this->players);
if ($manual) { if ($manual) {
Notification::make()->title('Calculation needs 10 player on field') Notification::make()->title('Calculation needs 10 player on field')
->info() ->info()
+3 -2
View File
@@ -18,6 +18,7 @@ class PlayerPropsTable extends TableWidget
use InteractsWithForms; use InteractsWithForms;
protected int|string|array $columnSpan = 2; protected int|string|array $columnSpan = 2;
public int $team_id; public int $team_id;
public array $players; public array $players;
@@ -56,7 +57,7 @@ class PlayerPropsTable extends TableWidget
->emptyStateHeading('No team selected') ->emptyStateHeading('No team selected')
->columns([ ->columns([
ViewColumn::make('drag_card') ViewColumn::make('drag_card')
->label(fn() => $this->getHeadingTable()) ->label(fn () => $this->getHeadingTable())
->view('filament.tables.columns.drag-card'), ->view('filament.tables.columns.drag-card'),
])->extraAttributes([ ])->extraAttributes([
'id' => 'playerdragtable', 'id' => 'playerdragtable',
@@ -86,7 +87,7 @@ class PlayerPropsTable extends TableWidget
], layout: FiltersLayout::AboveContent) ], layout: FiltersLayout::AboveContent)
->deferFilters(false) ->deferFilters(false)
->records(function () { ->records(function () {
$collection = collect($this->players); $collection = collect($this->players)->sortBy('order');
$selectedPosition = $this->tableFilters['positions']['area'] ?? null; $selectedPosition = $this->tableFilters['positions']['area'] ?? null;
if (! empty($selectedPosition)) { if (! empty($selectedPosition)) {
$collection = $collection->where('area', $selectedPosition); $collection = $collection->where('area', $selectedPosition);
+6
View File
@@ -55,22 +55,28 @@ class PlayerCalculator extends Component
if (! isset($val->details)) { if (! isset($val->details)) {
$tmp['area'] = 'goalkeeper'; $tmp['area'] = 'goalkeeper';
$tmp['color_pos'] = 'gray'; $tmp['color_pos'] = 'gray';
$tmp['order'] = 5;
} else { } else {
if (in_array($val->details->position, $positions_map['MIDFIELD'])) { if (in_array($val->details->position, $positions_map['MIDFIELD'])) {
$tmp['area'] = 'midfield'; $tmp['area'] = 'midfield';
$tmp['color_pos'] = 'info'; $tmp['color_pos'] = 'info';
$tmp['order'] = 2;
} elseif (in_array($val->details->position, $positions_map['DEFENCE'])) { } elseif (in_array($val->details->position, $positions_map['DEFENCE'])) {
$tmp['area'] = 'defence'; $tmp['area'] = 'defence';
$tmp['color_pos'] = 'success'; $tmp['color_pos'] = 'success';
$tmp['order'] = 1;
} elseif (in_array($val->details->position, $positions_map['ATTACK'])) { } elseif (in_array($val->details->position, $positions_map['ATTACK'])) {
$tmp['area'] = 'attack'; $tmp['area'] = 'attack';
$tmp['color_pos'] = 'warning'; $tmp['color_pos'] = 'warning';
$tmp['order'] = 3;
} elseif (in_array($val->details->position, $positions_map['GOALKEEPER'])) { } elseif (in_array($val->details->position, $positions_map['GOALKEEPER'])) {
$tmp['area'] = 'goalkeeper'; $tmp['area'] = 'goalkeeper';
$tmp['color_pos'] = 'gray'; $tmp['color_pos'] = 'gray';
$tmp['order'] = 4;
} else { } else {
$tmp['area'] = 'defence'; $tmp['area'] = 'defence';
$tmp['color_pos'] = 'success'; $tmp['color_pos'] = 'success';
$tmp['order'] = 5;
} }
} }
@@ -14,12 +14,12 @@
<div>{{ $record['foot'] }}</div> <div>{{ $record['foot'] }}</div>
<div>{{ $record['tot_evt'] }}</div> <div>{{ $record['tot_evt'] }}</div>
<div>{{ $record['ave_min'] }}</div> <div>{{ $record['ave_min'] }}</div>
<div class="bg-black text-white rounded font-bold">{{ $record['pos'] }}</div> <div class="bg-black text-white rounded font-bold p-0.5">{{ $record['pos'] }}</div>
</div> </div>
<div class="w-18 font-stretch-ultra-condensed"> <div class="text-center">
<x-filament::badge size="sm" color="{{ $record['color_pos'] }}"> <div class="{{ $record['color_pos'] }}">
{{ ucfirst($record['pos_ori']) }} {{ ucfirst($record['pos_ori']) }}
</x-filament::badge> </div>
</div> </div>
<div class="text-left text-sm tracking-tight flex-1 text-red-500"> <div class="text-left text-sm tracking-tight flex-1 text-red-500">
{{ $record['name'] }} {{ $record['name'] }}
@@ -22,12 +22,14 @@
</div> </div>
</x-slot> </x-slot>
</x-filament::modal> </x-filament::modal>
<x-filament::button icon="phosphor-arrows-clockwise" tooltip="Clear all" wire:click="clearResultTable()" /> <x-filament::button icon="phosphor-x" tooltip="Clear all" wire:click="clearResultTable()" />
<x-filament::button icon="phosphor-arrows-clockwise" tooltip="Reload" wire:click="loadPlacement()" />
<x-filament::button icon="phosphor-calculator" tooltip="Calculate" wire:click="calculateAspg(1)" /> <x-filament::button icon="phosphor-calculator" tooltip="Calculate" wire:click="calculateAspg(1)" />
<x-filament::button icon="phosphor-copy" color="success" <x-filament::button icon="phosphor-copy" color="success"
tooltip="Copy results for pasting into a spread sheet" wire:click="copyResult()" /> tooltip="Copy results for pasting into a spread sheet" wire:click="copyResult()" />
<x-filament::button icon="phosphor-copy" color="warning" tooltip="Copy calculation variables" <x-filament::button icon="phosphor-copy" color="warning" tooltip="Copy calculation variables"
wire:click="copyDevelopment()" /> wire:click="copyDevelopment()" />
{{-- --}}
</div> </div>
</div> </div>
<div class="border border-gray-500 w-full p-3 rounded grid grid-cols-7 grid-rows-5 gap-2 bg-cover bg-center bg-no-repeat aspect-7/5 shadow" <div class="border border-gray-500 w-full p-3 rounded grid grid-cols-7 grid-rows-5 gap-2 bg-cover bg-center bg-no-repeat aspect-7/5 shadow"