onQueue(config('restaurant-delivery.queue.queues.notifications', 'restaurant-delivery-notifications')); } /** * Get the notification's delivery channels. */ public function via(object $notifiable): array { return array_filter(config('restaurant-delivery.notifications.channels', ['database'])); } /** * Get the mail representation of the notification. */ public function toMail(object $notifiable): MailMessage { return (new MailMessage) ->subject("Delivery Update: {$this->delivery->status->label()}") ->greeting('Hello!') ->line("Your delivery #{$this->delivery->tracking_code} status has been updated.") ->line("New Status: {$this->delivery->status->label()}") ->line($this->delivery->status->description()) ->action('Track Delivery', $this->getTrackingUrl()) ->line('Thank you for using our delivery service!'); } /** * Get the array representation of the notification. */ public function toArray(object $notifiable): array { return [ 'type' => 'delivery_status', 'delivery_id' => $this->delivery->id, 'tracking_code' => $this->delivery->tracking_code, 'status' => $this->delivery->status->value, 'status_label' => $this->delivery->status->label(), 'status_description' => $this->delivery->status->description(), 'rider' => $this->delivery->rider ? [ 'name' => $this->delivery->rider->full_name, 'phone' => $this->delivery->rider->phone, ] : null, ]; } /** * Get FCM data for push notification. */ public function toFcm(): array { return [ 'title' => 'Delivery Update', 'body' => $this->delivery->status->description(), 'data' => [ 'type' => 'delivery_status', 'delivery_id' => (string) $this->delivery->id, 'tracking_code' => $this->delivery->tracking_code, 'status' => $this->delivery->status->value, ], ]; } /** * Get tracking URL. */ protected function getTrackingUrl(): string { return url("/track/{$this->delivery->tracking_code}"); } }