label('Archivieren') ->color('gray') ->visible(fn (): bool => $this->getRecord()->archived_at === null) ->requiresConfirmation() ->modalDescription('Das Anliegen wird in neuen Fassungen von Vorlagen nicht mehr angeboten. Bereits eingegangene Anfragen und veröffentlichte Fassungen bleiben unverändert.') ->action(function (): void { /** @var InquiryIssue $issue */ $issue = $this->getRecord(); $issue->forceFill(['archived_at' => now(), 'active' => false])->save(); foreach ($issue->children as $child) { $child->forceFill(['archived_at' => $child->archived_at ?? now(), 'active' => false])->save(); } Notification::make()->title('Archiviert.')->success()->send(); $this->redirect(InquiryIssueResource::getUrl('index')); }), 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. Das Anliegen ist weiterhin deaktiviert, bis es eingeschaltet wird.')->success()->send(); $this->redirect(InquiryIssueResource::getUrl('edit', ['record' => $this->getRecord()])); }), ]; } protected function getRedirectUrl(): ?string { return InquiryIssueResource::getUrl('index'); } }