*/ public function via(object $notifiable): array { return ['database']; } /** * @return array */ public function toDatabase(object $notifiable): array { $title = match ($this->status) { 'ready' => 'Review Pack ready', 'failed' => 'Review Pack generation failed', default => 'Review Pack status updated', }; $body = match ($this->status) { 'ready' => 'Your tenant review pack has been generated and is ready for download.', 'failed' => sprintf( 'Review pack generation failed%s.', $this->reasonCode ? ": {$this->reasonCode}" : '', ), default => 'Review pack status changed.', }; $color = match ($this->status) { 'ready' => 'success', 'failed' => 'danger', default => 'gray', }; $icon = match ($this->status) { 'ready' => 'heroicon-o-document-arrow-down', 'failed' => 'heroicon-o-exclamation-triangle', default => 'heroicon-o-document-text', }; $actions = []; $tenant = $this->reviewPack->tenant; if ($tenant instanceof Tenant && $this->status === 'ready') { $actions[] = Action::make('view_pack') ->label('View pack') ->url(route('filament.admin.resources.review-packs.view', [ 'tenant' => $tenant->external_id, 'record' => $this->reviewPack->getKey(), ])) ->toArray(); } return [ 'format' => 'filament', 'title' => $title, 'body' => $body, 'color' => $color, 'duration' => 'persistent', 'actions' => $actions, 'icon' => $icon, 'iconColor' => $color, 'status' => null, 'view' => null, 'viewData' => [ 'review_pack_id' => $this->reviewPack->getKey(), 'status' => $this->status, 'reason_code' => $this->reasonCode, ], ]; } }