*/ protected function archiveAttributes(): array { return ['archived_at' => now(), 'active' => false]; } /** Grund, warum das Archivieren gerade nicht möglich ist; null: möglich. */ protected function archiveBlocked(): ?string { return null; } /** * @return list */ protected function archiveActions(): array { return [ Action::make('archive') ->label('Archivieren') ->color('gray') ->visible(fn (): bool => $this->getRecord()->archived_at === null) ->requiresConfirmation() ->modalDescription(fn (): string => $this->archiveNote()) ->action(function (): void { if (($reason = $this->archiveBlocked()) !== null) { Notification::make()->title($reason)->danger()->send(); return; } $this->getRecord()->forceFill($this->archiveAttributes())->save(); Notification::make()->title('Archiviert.')->success()->send(); $this->redirect($this->indexUrl()); }), Action::make('restore') ->label('Wiederherstellen') ->color('gray') ->visible(fn (): bool => $this->getRecord()->archived_at !== null) ->action(function (): void { $this->getRecord()->forceFill(['archived_at' => null])->save(); Notification::make()->title('Wiederhergestellt.')->success()->send(); $this->redirect($this->indexUrl()); }), ]; } }