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('
Gls
Fls
Ofs
Snt
Tsh
Crd
Foot
Evt
Min Ø
'); } 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' => 'Attack', 'midfield' => 'Midfield', 'defence' => 'Defence', 'goalkeeper' => 'Goalkeeper', ])->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; }); } }