label('Löschen') ->color('danger') ->requiresConfirmation() ->action(function (): void { /** @var Pillar $pillar */ $pillar = $this->getRecord(); $deleted = false; $this->report(function () use ($pillar, &$deleted): void { app(PillarService::class)->delete($pillar); $deleted = true; }, 'Die Säule ist gelöscht.'); if ($deleted) { $this->redirect(PillarResource::getUrl('index')); } }), ]; } protected function mutateFormDataBeforeFill(array $data): array { $data['published'] = $this->getRecord()->published_at !== null; return $data; } protected function handleRecordUpdate(Model $record, array $data): Model { /** @var Pillar $record */ try { app(PillarService::class)->present( $record, (string) $data['name'], (string) ($data['slug'] ?? ''), $data['public_summary'] ?? null, (bool) ($data['published'] ?? false), (int) ($data['sort_order'] ?? 0), ); } catch (DomainRuleException $exception) { Notification::make()->title($exception->getMessage())->danger()->send(); throw new Halt; } return $record; } }