actionType = $actionType; $this->messageTitle = $messageTitle; $this->messageBody = $messageBody; $this->daysRemaining = $daysRemaining; $this->reminderLevel = $reminderLevel; $this->entityType = $entityType; $this->entityId = $entityId; } /** * Get the notification's delivery channels. */ public function via($notifiable): array { $channels = ['database']; // Determine if email channel should be included $emailEnabled = true; if (method_exists($notifiable, 'employerProfile') && $notifiable->employerProfile) { $emailEnabled = (bool) ($notifiable->employerProfile->email_notifications ?? true); } if ($emailEnabled && !empty($notifiable->email)) { $channels[] = 'mail'; } // Determine if push channel should be included $pushEnabled = true; if (method_exists($notifiable, 'employerProfile') && $notifiable->employerProfile) { $pushEnabled = (bool) ($notifiable->employerProfile->push_notifications ?? true); } if ($pushEnabled && !empty($notifiable->fcm_token)) { $channels[] = FcmChannel::class; } return $channels; } /** * Get the mail representation of the notification. */ public function toMail($notifiable): MailMessage { $name = $notifiable->name ?? $notifiable->full_name ?? 'User'; return (new MailMessage) ->subject("Pending Action: {$this->messageTitle}") ->greeting("Hello {$name},") ->line($this->messageBody) ->line("This action is pending and needs your confirmation within {$this->daysRemaining} days.") ->action('View Actions', url('/dashboard')) ->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' => $this->messageTitle, 'body' => $this->messageBody, 'action_type' => $this->actionType, 'days_remaining' => $this->daysRemaining, 'reminder_level' => $this->reminderLevel, 'entity_type' => $this->entityType, 'entity_id' => $this->entityId, 'type' => 'pending_confirmation', ]; } /** * Get the push notification representation. */ public function toFcm($notifiable): array { return [ 'token' => $notifiable->fcm_token, 'title' => $this->messageTitle, 'body' => $this->messageBody, 'data' => [ 'type' => 'pending_confirmation', 'action_type' => $this->actionType, 'entity_id' => $this->entityId, 'days_remaining' => $this->daysRemaining, ], ]; } }