components([ TextInput::make('geschoss') ->required() ->maxLength(255), ]); } public function table(Table $table): Table { return $table ->striped() ->recordTitleAttribute('top_nummer') ->columns([ TextColumn::make('top_nummer') ->extraAttributes(['pointer-events' => 'none']) ->searchable() ->label('Top'), TextColumn::make('geschoss')->searchable(), TextColumn::make('raumart')->searchable(), TextInputColumn::make('faktor') ->suffixIcon('phosphor-function') ->width('1rem') ->rules(['required', 'faktor' => 'decimal:0,2']) ->searchable(), TextInputColumn::make('flaeche') ->summarize(Sum::make()->label('Gesammt')->numeric( decimalPlaces: 2, )->suffix(new HtmlString(' m²'))) ->suffix(new HtmlString(' m²')) ->width('2rem') ->alignment('right') ->rules(['required', 'flaeche' => 'decimal:2']) ->label('Fläche') ->searchable(), TextColumn::make('nutzwert') ->alignCenter() ->default(fn ($record): ?int => round($record->faktor * $record->flaeche)) ->weight(FontWeight::ExtraBold), ]) ->filters([ SelectFilter::make('top_nummer') ->label('Top Nummer') ->searchable() ->options(function (): array { return Raeumealle::where('projekte_id', $this->getOwnerRecord()->id)->groupBy('top_nummer')->orderBy('top_nummer')->pluck('top_nummer', 'top_nummer')->toArray(); }), SelectFilter::make('geschoss') ->searchable() ->options(function (): array { return Raeumealle::where('projekte_id', $this->getOwnerRecord()->id)->groupBy('geschoss')->orderBy('geschoss')->pluck('geschoss', 'geschoss')->toArray(); }), SelectFilter::make('raumart') ->searchable() ->options(function (): array { return Raeumealle::where('projekte_id', $this->getOwnerRecord()->id)->groupBy('raumart')->orderBy('raumart')->pluck('raumart', 'raumart')->toArray(); }), ]) // ], layout: FiltersLayout::AboveContentCollapsible) ->headerActions([ CreateAction::make() ->icon('phosphor-file-plus') ->createAnother(false), ImportAction::make() ->importer(RaeumealleImporter::class) ->label('Hochladen') ->icon('phosphor-upload') ->color('info') ->options([ 'projekte_id' => $this->getOwnerRecord()->id, ]) ->fileRules([ File::types(['csv', 'txt'])->max(1024), ]), ]) ->recordActions([ EditAction::make()->iconButton()->color('gray'), DeleteAction::make()->iconButton(), ]) ->toolbarActions([ BulkActionGroup::make([ BulkAction::make('faktor') ->color('primary') ->label('Faktor zuweisen') ->schema([ TextInput::make('faktor') ->prefixIcon('phosphor-calculator') ->numeric() ->required(), ]) ->icon('phosphor-calculator') ->action(function (Collection $records, array $data): void { foreach ($records as $record) { Raeumealle::where('id', '=', $record->id) ->update( ['faktor' => $data['faktor']] ); } }), DeleteBulkAction::make(), ]), ]); } }