revision = $revision; $this->certificateContent = $certificateContent; $this->event = $event; } /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return ['mail', 'database', FcmChannel::class]; } /** * Get the mail representation of the notification. * * @param mixed $notifiable * @return MailMessage */ public function toMail($notifiable) { return (new MailMessage) ->markdown('emails.issued.certificate', [ 'event' => $this->event, 'user' => $notifiable, 'verificationUrl' => $this->revision->issuedCertificate->verificationUrl(), ]) ->attachData(Storage::disk($this->revision->pdf_disk)->get($this->revision->pdf_path), 'certificate.pdf', [ 'mime' => 'application/pdf', ]); } /** * Get the array representation of the notification. * * @param mixed $notifiable * @return array */ public function toArray($notifiable) { $details['meeting_title'] = 'Certificate issued'; $details['event_id'] = $this->event->id; $details['message'] = $this->generateMessage(); $details['user_id'] = $notifiable->id; return [ 'data' => $details, ]; } public function generateMessage(): string { $event = $this->event; return 'Organizers of '. $event->title. ' dated '. date_format( date_create($event->timings['event_start_and_end']['start']), 'd M Y' ). ' - '. date_format( date_create($event->timings['event_start_and_end']['end']), 'd M Y' ). ' have issued your certificates'; } public function toFcm($notifiable) { return FcmMessage::create() ->setData(['data1' => $this->details['meeting_title'], 'data2' => $this->details['message'], 'data3' => $this->id]) ->setNotification(\NotificationChannels\Fcm\Resources\Notification::create() ->setTitle($this->details['meeting_title']) ->setBody($this->details['message']) ->setImage(public_path('apple-touch-icon-120x120.png'))) ->setAndroid( AndroidConfig::create() ->setFcmOptions(AndroidFcmOptions::create()->setAnalyticsLabel('analytics')) ->setNotification(AndroidNotification::create()->setColor('#0A0A0A')) )->setApns( ApnsConfig::create() ->setFcmOptions(ApnsFcmOptions::create()->setAnalyticsLabel('analytics_ios'))); } // optional method when using kreait/laravel-firebase:^3.0, this method can be omitted, defaults to the default project // public function fcmProject($notifiable, $message) // { // // $message is what is returned by `toFcm` // return 'app'; // name of the firebase project to use // } }