place calculator an separate page

This commit is contained in:
salam committed 2026-09-14 12:33:40 +02:00
1 parent 26052c6cfd
commit ed8a50d044
14 files changed
+777 -306

No files matched your search

+57 -106
View File
@@ -8,6 +8,7 @@ use App\Actions\LoadStatisticFixturesMatchOptions;
use App\Filament\Widgets\PlayerPropsDrop;
use App\Filament\Widgets\PlayerPropsTable;
use App\Models\SofaScoreRosa;
use App\Models\SsLineupMemory;
use App\Models\StatisticFixtures;
use BackedEnum;
use Filament\Forms\Components\Select;
@@ -16,6 +17,8 @@ use Filament\Forms\Contracts\HasForms;
use Filament\Pages\Page;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Schema;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\On;
class PlayerProps extends Page implements HasForms
{
@@ -34,66 +37,43 @@ class PlayerProps extends Page implements HasForms
protected static ?int $navigationSort = 2;
public array $boxes;
public array $activeBoxes;
public array $sourceRecords;
public ?array $filterData;
public array $beschriftung;
public array $lineup;
public array $lineUpOptinos;
public array $lineUpMap;
public string $activeLineUp = '3313';
public string $lineupActive = '3313';
public array $players = [];
public array $clientLineUps = [];
public int $team_id;
public function mount(): void
{
// Initialisiert das Formular mit leeren Werten
$this->form->fill();
$this->activeBoxes = $this->boxNames();
$this->lineUpMap = $this->linUpMap();
$this->lineUpOptinos = $this->lineUpOptinos();
$this->lineup = $this->lineUpMap[$this->lineupActive];
for ($i = 1; $i <= 35; $i++) {
$this->boxes[$i] = [];
if (isset($this->activeBoxes[$i])) {
$this->beschriftung[$i] = $this->activeBoxes[$i];
} else {
$this->beschriftung[$i] = '';
}
}
}
public function getWidgetData(): array
{
return [
'beschriftung' => $this->beschriftung,
'lineup' => $this->lineup,
'boxes' => $this->boxes,
'activeLineUp' => $this->activeLineUp,
];
}
public function form(Schema $schema): Schema
{
return $schema
->columns(4)
->columns(5)
->components([
Select::make('cid')
->live()
->preload()
->searchable(false)
->prefixIconColor(fn (Get $get): string => $get('cid') ? 'success' : 'danger')
->prefixIconColor(fn(Get $get): string => $get('cid') ? 'success' : 'danger')
->prefixIcon('phosphor-globe-fill')
->hiddenLabel()
->options(fn () => LoadSofaScoreCategory::load())
->options(fn() => LoadSofaScoreCategory::load())
->placeholder('Country')
->afterStateUpdated(function (callable $set, $state) {
$set('lid', null);
@@ -103,10 +83,10 @@ class PlayerProps extends Page implements HasForms
Select::make('lid')
->live()
->preload()
->prefixIconColor(fn (Get $get): string => $get('lid') ? 'success' : 'danger')
->prefixIconColor(fn(Get $get): string => $get('lid') ? 'success' : 'danger')
->prefixIcon('phosphor-trophy-fill')
->hiddenLabel()
->options(fn (Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('cid')))
->options(fn(Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('cid')))
->placeholder('League')
->afterStateUpdated(function (callable $set) {
$set('mid', null);
@@ -115,12 +95,13 @@ class PlayerProps extends Page implements HasForms
Select::make('mid')
->live()
->hiddenLabel()
->prefixIconColor(fn (Get $get): string => $get('mid') ? 'success' : 'danger')
->prefixIconColor(fn(Get $get): string => $get('mid') ? 'success' : 'danger')
->prefixIcon('phosphor-calendar-check-fill')
->options(function (Get $get) {
return LoadStatisticFixturesMatchOptions::load($get('lid'));
})
->afterStateUpdated(function (callable $set) {
->afterStateUpdated(function (callable $set, $state) {
$this->dispatch('match-update', match_id: $state);
$set('tid', null);
})
->placeholder('Events'),
@@ -128,7 +109,7 @@ class PlayerProps extends Page implements HasForms
Select::make('tid')
->live()
->hiddenLabel()
->prefixIconColor(fn (Get $get): string => $get('tid') ? 'success' : 'danger')
->prefixIconColor(fn(Get $get): string => $get('tid') ? 'success' : 'danger')
->prefixIcon('phosphor-users-three-fill')
->options(function (Get $get) {
if ($get('mid')) {
@@ -144,33 +125,58 @@ class PlayerProps extends Page implements HasForms
}
})
->placeholder('Team')->afterStateUpdated(function ($state) {
// Speichert das ausgewählte Team direkt in der Session
// session(['player_props_filter_team' => $state]);
// Widget informieren
$this->dispatch('refreshFilters', team_id: $state);
$this->dispatch('team-update', team_id: $state);
}),
Select::make('lineup')
->live()
->hiddenLabel()
->allowHtml()
->native(false)
->prefixIconColor('info')
->prefixIcon('icon-soccerfield-fill')
->options(function () {
$res = $this->lineUpOptinos();
$arr = [];
foreach ($res as $key => $value) {
if ($this->players && in_array($key, $this->clientLineUps))
$arr[$key] = $value . '<span class="text-blue-600"> has lineup</span>';
else
$arr[$key] = $value;
}
return $arr;
})
->placeholder('LineUp')
->searchable()
->default($this->activeLineUp)
->afterStateUpdated(function ($state) {
$this->dispatch('lineup-update', activeLineUp: $state);
}),
])->statePath('filterData');
}
#[On('team-update')]
public function syncData(int $team_id)
{
$this->team_id = $team_id;
$this->clientLineUps = SsLineupMemory::where('team_id', $team_id)->where('client_id', Auth::user()->client_id)->pluck('lineup')->toArray();
}
#[On('update-players')]
public function updatePlayers(array $players)
{
$this->players = $players;
}
protected function getFooterWidgets(): array
{
return [
PlayerPropsTable::class,
PlayerPropsDrop::class,
PlayerPropsTable::make(['players' => $this->players]),
PlayerPropsDrop::make(['players' => $this->players]),
];
}
public function getFooterWidgetsColumns(): int|array
{
return 5;
}
private function boxNames(): array
{
return [2 => 'DR', 4 => 'MR', 6 => 'LW', 9 => 'DC', 10 => 'DM', 11 => 'MC', 12 => 'AM', 15 => 'SW', 16 => 'DC', 17 => 'DM', 18 => 'MC', 19 => 'AM', 20 => 'SM', 21 => 'ST', 23 => 'DC', 24 => 'DM', 25 => 'MC', 26 => 'AM', 30 => 'DL', 32 => 'ML', 34 => 'RW'];
}
private function lineUpOptinos(): array
{
return [
@@ -225,59 +231,4 @@ class PlayerProps extends Page implements HasForms
'541+' => '541+',
];
}
private function linUpMap(): array
{
return [
'3313' => [9, 16, 23, 11, 18, 25, 19, 6, 34, 21],
'3331' => [9, 16, 23, 17, 11, 25, 12, 19, 26, 21],
'3331-' => [9, 16, 23, 10, 18, 24, 12, 19, 26, 21],
'3331+' => [9, 16, 23, 11, 18, 25, 12, 19, 26, 21],
'3412-' => [9, 16, 23, 4, 10, 24, 32, 19, 20, 21],
'3412+' => [9, 16, 23, 4, 11, 25, 32, 19, 20, 21],
'3421-' => [9, 16, 23, 4, 10, 24, 32, 12, 26, 21],
'3421+' => [9, 16, 23, 4, 11, 25, 32, 12, 26, 21],
'343-' => [9, 16, 23, 4, 10, 24, 32, 6, 34, 21],
'343+' => [9, 16, 23, 4, 11, 25, 32, 6, 34, 21],
'3511' => [9, 16, 23, 4, 11, 17, 25, 32, 19, 21],
'3511-' => [9, 16, 23, 4, 10, 18, 24, 32, 19, 21],
'3511+' => [9, 16, 23, 4, 11, 18, 25, 32, 19, 21],
'352' => [9, 16, 23, 4, 11, 17, 25, 32, 20, 21],
'352-' => [9, 16, 23, 4, 10, 18, 24, 32, 20, 21],
'352+' => [9, 16, 23, 4, 11, 18, 25, 32, 20, 21],
'4132' => [2, 9, 23, 30, 17, 12, 19, 26, 20, 21],
'4213-' => [2, 9, 23, 30, 10, 24, 19, 6, 34, 21],
'4213+' => [2, 9, 23, 30, 11, 25, 19, 6, 34, 21],
'4222' => [2, 9, 23, 30, 10, 24, 12, 26, 20, 21],
'4231' => [2, 9, 23, 30, 10, 24, 12, 19, 26, 21],
'424' => [2, 9, 23, 30, 10, 24, 6, 34, 20, 21],
'4312' => [2, 9, 23, 30, 17, 11, 25, 19, 20, 21],
'4312-' => [2, 9, 23, 30, 10, 18, 24, 19, 20, 21],
'4312+' => [2, 9, 23, 30, 11, 18, 25, 19, 20, 21],
'4321' => [2, 9, 23, 30, 17, 11, 25, 12, 26, 21],
'4321-' => [2, 9, 23, 30, 10, 18, 24, 12, 26, 21],
'4321+' => [2, 9, 23, 30, 11, 18, 25, 12, 26, 21],
'433' => [2, 9, 23, 30, 17, 11, 25, 6, 34, 21],
'433-' => [2, 9, 23, 30, 10, 18, 24, 6, 34, 21],
'433+' => [2, 9, 23, 30, 11, 18, 25, 6, 34, 21],
'4411-' => [2, 9, 23, 30, 4, 10, 24, 32, 19, 21],
'4411+' => [2, 9, 23, 30, 4, 11, 25, 32, 19, 21],
'442' => [2, 9, 23, 30, 4, 17, 18, 32, 20, 21],
'442-' => [2, 9, 23, 30, 4, 10, 24, 32, 20, 21],
'442+' => [2, 9, 23, 30, 4, 11, 25, 32, 20, 21],
'451' => [2, 9, 23, 30, 4, 17, 11, 25, 32, 21],
'451-' => [2, 9, 23, 30, 4, 10, 18, 24, 32, 21],
'451+' => [2, 9, 23, 30, 4, 11, 18, 25, 32, 21],
'523-' => [2, 9, 16, 23, 30, 10, 24, 6, 34, 21],
'523+' => [2, 9, 16, 23, 30, 11, 25, 6, 34, 21],
'5311' => [2, 9, 16, 23, 30, 17, 11, 25, 19, 21],
'5311-' => [2, 9, 16, 23, 30, 10, 18, 24, 19, 21],
'5311+' => [2, 9, 16, 23, 30, 11, 18, 25, 19, 21],
'532' => [2, 9, 16, 23, 30, 17, 11, 25, 20, 21],
'532-' => [2, 9, 16, 23, 30, 10, 18, 24, 20, 21],
'532+' => [2, 9, 16, 23, 30, 11, 18, 25, 20, 21],
'541-' => [2, 9, 16, 23, 30, 4, 10, 24, 32, 21],
'541+' => [2, 9, 16, 23, 30, 4, 11, 25, 32, 21],
];
}
}