This commit is contained in:
salam committed 2026-09-13 15:40:30 +02:00
1 parent 08a1522868
commit 26052c6cfd
15 files changed
+594 -62

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Filament\Widgets;
use Filament\Widgets\Widget;
class PlayerPropsDrop extends Widget
{
protected string $view = 'livewire.player-props-drop';
public array $beschriftung;
public array $lineup;
public array $boxes;
}
+144
View File
@@ -0,0 +1,144 @@
<?php
namespace App\Filament\Widgets;
use App\Livewire\PlayerCalculator;
use App\Models\SofaScoreRosa;
use App\Models\User;
use Filament\Actions\Action;
use Filament\Forms\Components\Select;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Support\Enums\SlideOverPosition;
use Filament\Support\Enums\Width;
use Filament\Tables\Columns\ViewColumn;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\HtmlString;
use Livewire\Attributes\On;
use Livewire\Attributes\Reactive;
class PlayerPropsTable extends TableWidget
{
use InteractsWithForms;
protected int|string|array $columnSpan = 2;
public string $team_name = '';
// #[Reactive]
public array $sourceRecords = [];
#[On('refreshFilters')]
public function refreshTable(?int $team_id = 0): void
{
if ($team_id) {
$this->team_name = SofaScoreRosa::where('ss_team_id', $team_id)->value('ss_team_name');
$this->sourceRecords = PlayerCalculator::load($team_id);
$this->resetTable();
}
}
public function getHeadingTable(): HtmlString
{
return new HtmlString('<div class="text-[11px] p-0 flex flex-row gap-4 font-bold font-mono" style="position: relative; left: -2px; bottom: -13px;">
<div>Gls</div>
<div>Fls</div>
<div>Ofs</div>
<div>Snt</div>
<div>Tsh</div>
<div>Crd</div>
<div>Foot</div>
<div>Evt</div>
<div>Min Ø</div>
</div>');
}
public function table(Table $table): Table
{
return $table
->headerActions([
Action::make('esc')
->hiddenLabel()
->tooltip('Clear all (esc)')
->icon('phosphor-x-circle')
->color('gray')
->keyBindings(['esc'])
->action(fn () => $this->resetFilters()),
Action::make('lineups')
->tooltip('Lineups explanation')
->color('success')
->hiddenLabel()
->icon('phosphor-question-mark')
->slideOver()
->slideOverPosition(SlideOverPosition::Start)
->modalWidth(Width::ExtraLarge)
->modalSubmitAction(false)
->modalCancelAction(false)
->modalContent(fn () => view('filament.modals.position-abbreviation')),
Action::make('reset')
->hiddenLabel()
->tooltip('Remove all')
->icon('phosphor-arrows-clockwise')
->action(fn () => $this->clearResultTable()),
Action::make('calculate')
->tooltip('Calculate')
->hiddenLabel()
->icon('phosphor-calculator')
->action(fn () => $this->calculateAspg()),
Action::make('copy_results')
->tooltip('Copy results for pasting into a spread sheet')
->hiddenLabel()
->icon('phosphor-copy')
->action(fn () => $this->copyResult()),
Action::make('copy_development')
->tooltip('Copy calculation variables')
->hiddenLabel()
->hidden(fn () => ! in_array(Auth::user()->id, [1, 2]))
->color('warning')
->icon('phosphor-copy')
->action(fn () => $this->copyDevelopment()),
])
->heading($this->team_name)
->query(User::query()->whereRaw('1 = 0')) // Verhindert DB-Abfragen
->striped()
->defaultSort('name')
->emptyStateHeading('No team selected')
->columns([
ViewColumn::make('drag_card')
->label(fn () => $this->getHeadingTable())
->view('filament.tables.columns.drag-card'),
])->extraAttributes([
'id' => 'playerdragtable',
])
->filters([
SelectFilter::make('area')
->columnSpanFull()
->native(false)
->options([
'attack' => '<span class="text-amber-500">Attack</span>',
'midfield' => '<span class="text-blue-500">Midfield</span>',
'defence' => '<span class="text-green-500">Defence</span>',
'goalkeeper' => '<span class="text-gray-500">Goalkeeper</span>',
])->modifyFormFieldUsing(fn (Select $component) => $component->allowHtml())
->query(function ($query) {
return $query;
})->indicateUsing(function (array $data): array {
// WICHTIG: Ein leeres Array sorgt dafür, dass kein Indicator-Badge erzeugt wird
return [];
}),
], layout: FiltersLayout::AboveContent)
->deferFilters(false)
->records(function () {
$collection = collect($this->sourceRecords);
$selectedPosition = $this->tableFilters['area']['value'] ?? null;
if (! empty($selectedPosition)) {
$collection = $collection->where('area', $selectedPosition);
}
return $collection;
});
}
}
+1 -2
View File
@@ -240,7 +240,6 @@ class StatsMedianAverage extends StatsOverviewWidget
return $boxes;
}
// TEAMPLATE BOX 1
protected function template_box1(float $expectations_home, float $expectations_away): HtmlString
@@ -338,7 +337,7 @@ class StatsMedianAverage extends StatsOverviewWidget
}
} else {
// odd (add 1 because array starts with 0)
$m = ceil($size / 2);
$m = (int) ceil($size / 2);
// dd($m, $arr);
// dd('UNGERADE', $m, $arr, $arr[$m]);
if (isset($arr[$m])) {