getRecord(); return $inquiry->contactTitle(); } public function getSubheading(): string|Htmlable|null { /** @var Inquiry $inquiry */ $inquiry = $this->getRecord(); return 'Anfrage '.$inquiry->reference.' vom '.$inquiry->created_at->format('d.m.Y H:i'); } protected function getHeaderActions(): array { return [ Action::make('status') ->label('Status ändern') ->icon('heroicon-o-arrow-path') ->modalHeading('Bearbeitungsstatus') ->modalSubmitActionLabel('Status speichern') ->fillForm(fn (): array => ['status' => $this->getRecord()->status->value]) ->schema([Select::make('status')->label('Neuer Status')->options(InquiryStatus::options())->required()]) ->action(function (array $data): void { $this->getRecord()->forceFill(['status' => $data['status']])->save(); Notification::make()->title('Der Status ist geändert.')->success()->send(); $this->refreshFormData(['status']); }), Action::make('note') ->label('Notiz hinzufügen') ->icon('heroicon-o-pencil-square') ->color('gray') ->modalHeading('Interne Notiz') ->modalDescription('Nur für das Team sichtbar, nie für den Anfragenden.') ->modalSubmitActionLabel('Notiz speichern') ->schema([Textarea::make('body')->label('Notiz')->required()->rows(4)->maxLength(4000)]) ->action(function (array $data): void { InquiryNote::query()->create([ 'inquiry_id' => $this->getRecord()->id, 'user_id' => CommunicationAccess::user()?->id, 'body' => $data['body'], ]); $this->getRecord()->load('notes'); Notification::make()->title('Die Notiz ist gespeichert.')->success()->send(); $this->redirect(InquiryResource::getUrl('view', ['record' => $this->getRecord()])); }), Action::make('resend') ->label('Benachrichtigung erneut senden') ->icon('heroicon-o-envelope') ->color('gray') ->visible(fn (): bool => $this->getRecord()->notified_at === null) ->requiresConfirmation() ->modalDescription('Sendet die interne Benachrichtigung an die in den Einstellungen hinterlegten Empfänger noch einmal.') ->action(function (): void { SendInquiryNotification::dispatchSync($this->getRecord()->id, InquiryResource::getUrl('view', ['record' => $this->getRecord()])); $inquiry = $this->getRecord()->fresh(); if ($inquiry->notified_at !== null) { Notification::make()->title('Die Benachrichtigung ist gesendet.')->success()->send(); } else { Notification::make()->title('Die Benachrichtigung ist weiterhin fehlgeschlagen.')->body((string) $inquiry->notification_error)->danger()->send(); } $this->redirect(InquiryResource::getUrl('view', ['record' => $inquiry])); }), Action::make('erase') ->label('Anfrage löschen') ->icon('heroicon-o-trash') ->color('danger') ->visible(fn (): bool => CommunicationAccess::erase()) ->requiresConfirmation() ->modalHeading('Anfrage endgültig löschen?') ->modalDescription('Die Anfrage mit allen Antworten und Notizen wird unwiderruflich gelöscht, zum Beispiel auf Wunsch der betroffenen Person. Das lässt sich nicht rückgängig machen.') ->action(function (): void { $this->getRecord()->delete(); Notification::make()->title('Die Anfrage ist gelöscht.')->success()->send(); $this->redirect(InquiryResource::getUrl('index')); }), ]; } }