striped() ->recordTitleAttribute('raumart') ->columns([ SelectColumn::make('methode_id') ->selectablePlaceholder(true) ->optionsRelationship('methode', 'name') ->preloadOptions(), TextColumn::make('raumart') ->searchable(), TextInputColumn::make('faktor') ->suffixIcon('phosphor-function') ->width('1rem') ->rules(['required', 'faktor' => 'decimal:0,2']) ->searchable(), ]) ->filters([ TernaryFilter::make('methode_id') ->label('Methode zugeordnet'), ]) ->headerActions([ Action::make('erstellen') ->action(fn (CreateProjektMethoden $createProjektMethoden) => $createProjektMethoden->create($this->ownerRecord)) ->requiresConfirmation() ->modalHeading('Raum Methoden erstellen') ->modalDescription('Alle bestehenden Daten in dieser Tabelle werden vorher gelöscht.') ->modalSubmitActionLabel('Erstellen') ->label('Erstellen') ->tooltip('Daten werden aus "Räume Alle" Tabelle gefiltert.') ->icon('heroicon-o-cog-8-tooth'), ]) ->toolbarActions([ BulkActionGroup::make([ BulkAction::make('faktor') ->color('primary') ->label('Faktor zuweisen') ->schema([ TextInput::make('faktor') ->prefixIcon('phosphor-function') ->numeric() ->required(), ]) ->icon('phosphor-function') ->action(function (Collection $records, array $data): void { foreach ($records as $record) { ProjektMethode::where('id', '=', $record->id) ->update( ['faktor' => $data['faktor']] ); } }), BulkAction::make('methode') ->color('primary') ->label('Methode zuweisen') ->schema([ Select::make('methode_id') ->label('Methode') ->prefixIcon('phosphor-calculator') ->options(Methode::pluck('name', 'id')) ->required(), ]) ->icon('phosphor-calculator') ->action(function (Collection $records, array $data): void { foreach ($records as $record) { ProjektMethode::where('id', '=', $record->id) ->update( ['methode_id' => $data['methode_id']] ); } }), ]), ]); } }