*/ public function via(object $notifiable): array { $preferences = $notifiable->notification_preferences ?? []; $channels = $preferences['uptime'] ?? ['mail']; return $channels; } /** * Get the mail representation of the notification. */ public function toMail(object $notifiable): MailMessage { $status = $this->statusCode ? "returned HTTP {$this->statusCode}" : "is unreachable"; return (new MailMessage) ->error() ->subject("⚠️ Site Down Alert: {$this->site->name}") ->line("Your site **{$this->site->name}** is experiencing downtime.") ->line("URL: {$this->site->url}") ->line("Status: {$status}") ->line("Response Time: " . ($this->responseTime ? "{$this->responseTime}ms" : "N/A")) ->line("Detected at: " . now()->format('Y-m-d H:i:s')) ->action('View Site Details', url("/sites/{$this->site->id}")) ->line('Please investigate the issue as soon as possible.'); } /** * Get the array representation of the notification. * * @return array */ public function toArray(object $notifiable): array { return [ 'site_id' => $this->site->id, 'site_name' => $this->site->name, 'site_url' => $this->site->url, 'status_code' => $this->statusCode, 'response_time' => $this->responseTime, ]; } }