jobTitle = $jobTitle; $this->employerName = $employerName; $this->daysRemaining = $daysRemaining; $this->reminderLevel = $reminderLevel; $this->applicationId = $applicationId; } /** * Get the notification's delivery channels. */ public function via($notifiable): array { $channels = ['database']; // Emails are sent to workers by default if (!empty($notifiable->email)) { $channels[] = 'mail'; } // Push notifications are sent to workers if they have an FCM token if (!empty($notifiable->fcm_token)) { $channels[] = FcmChannel::class; } return $channels; } /** * Get the mail representation of the notification. */ public function toMail($notifiable): MailMessage { $name = $notifiable->name ?? 'Worker'; return (new MailMessage) ->subject("Action Required: Confirm Joining for {$this->jobTitle}") ->greeting("Hello {$name},") ->line("You have been hired by {$this->employerName} for the job: {$this->jobTitle}.") ->line("Please confirm your joining within {$this->daysRemaining} days before the job start date.") ->action('Confirm Joining Now', url("/worker/applications")) ->line('Thank you for using our application!'); } /** * Get the array representation of the notification for in-app storage. */ public function toArray($notifiable): array { return [ 'title' => "Pending Joining Confirmation", 'body' => "Please confirm you will join the job '{$this->jobTitle}' with {$this->employerName} in {$this->daysRemaining} days.", 'job_title' => $this->jobTitle, 'employer_name' => $this->employerName, 'days_remaining' => $this->daysRemaining, 'reminder_level' => $this->reminderLevel, 'application_id' => $this->applicationId, 'type' => 'joining_confirmation', ]; } /** * Get the push notification representation. */ public function toFcm($notifiable): array { return [ 'token' => $notifiable->fcm_token, 'title' => "Action Required: Confirm Joining", 'body' => "Please confirm your joining for '{$this->jobTitle}' within {$this->daysRemaining} days.", 'data' => [ 'type' => 'joining_confirmation', 'application_id' => $this->applicationId, 'days_remaining' => $this->daysRemaining, ], ]; } }