onQueue(config('restaurant-delivery.queue.queues.notifications', 'restaurant-delivery-notifications')); } /** * Get the notification's delivery channels. */ public function via(object $notifiable): array { return ['database']; } /** * Get the mail representation of the notification. */ public function toMail(object $notifiable): MailMessage { $rider = $this->delivery->rider; return (new MailMessage) ->subject('Rider Assigned to Your Delivery') ->greeting('Good news!') ->line("A rider has been assigned to your delivery #{$this->delivery->tracking_code}.") ->line("Rider: {$rider->full_name}") ->line("Vehicle: {$rider->vehicle_type}") ->action('Track Your Delivery', $this->getTrackingUrl()) ->line('You can now track your rider in real-time!'); } /** * Get the array representation of the notification. */ public function toArray(object $notifiable): array { $rider = $this->delivery->rider; return [ 'type' => 'rider_assigned', 'delivery_id' => $this->delivery->id, 'tracking_code' => $this->delivery->tracking_code, 'rider' => [ 'id' => $rider->id, 'name' => $rider->full_name, 'phone' => $rider->phone, 'photo' => $rider->photo_url, 'rating' => $rider->rating, 'vehicle_type' => $rider->vehicle_type, ], ]; } /** * Get FCM data for push notification. */ public function toFcm(): array { $rider = $this->delivery->rider; return [ 'title' => 'Rider Assigned', 'body' => "{$rider->full_name} is picking up your order", 'data' => [ 'type' => 'rider_assigned', 'delivery_id' => (string) $this->delivery->id, 'tracking_code' => $this->delivery->tracking_code, 'rider_id' => (string) $rider->id, 'rider_name' => $rider->full_name, ], ]; } /** * Get tracking URL. */ protected function getTrackingUrl(): string { return url("/track/{$this->delivery->tracking_code}"); } }