title = $title; $this->body = $body; $this->data = $data; } /** * Get the notification's delivery channels. */ public function via($notifiable): array { $channels = ['database']; if (!empty($notifiable->fcm_token)) { $channels[] = FcmChannel::class; } return $channels; } /** * Get the array representation of the notification for in-app database storage. */ public function toArray($notifiable): array { return array_merge([ 'title' => $this->title, 'body' => $this->body, ], $this->data); } /** * Get the push notification representation. */ public function toFcm($notifiable): array { return [ 'token' => $notifiable->fcm_token, 'title' => $this->title, 'body' => $this->body, 'data' => array_merge([ 'title' => $this->title, 'body' => $this->body, ], $this->data), ]; } }