*/ public function via(object $notifiable): array { return ['mail', 'database']; } /** * Get the mail representation of the notification. */ public function toMail(object $notifiable): MailMessage { $subject = $this->status === 'unhealthy' ? "Health Check Failed: {$this->healthCheck->endpoint}" : "Health Check Restored: {$this->healthCheck->endpoint}"; $message = (new MailMessage) ->subject($subject) ->line("Health check alert for {$this->healthCheck->site->name}"); if ($this->status === 'unhealthy') { $message->error() ->line("The health endpoint {$this->healthCheck->endpoint} is reporting as unhealthy.") ->line("This could indicate an application issue or service degradation."); if ($this->statusCode) { $message->line("HTTP Status Code: {$this->statusCode}"); } } else { $message->success() ->line("The health endpoint {$this->healthCheck->endpoint} is now healthy.") ->line("The service has been restored."); if ($this->statusCode) { $message->line("HTTP Status Code: {$this->statusCode}"); } if ($this->responseTime) { $message->line("Response Time: {$this->responseTime}ms"); } } return $message ->line("Endpoint: {$this->healthCheck->full_url}") ->line("Checked at: {$this->healthCheck->last_checked_at->format('Y-m-d H:i:s')}") ->action('View Details', url("/sites/{$this->healthCheck->site_id}")); } /** * Get the array representation of the notification. * * @return array */ public function toArray(object $notifiable): array { return [ 'type' => 'health_check', 'health_check_id' => $this->healthCheck->id, 'site_id' => $this->healthCheck->site_id, 'site_name' => $this->healthCheck->site->name, 'endpoint' => $this->healthCheck->endpoint, 'full_url' => $this->healthCheck->full_url, 'status' => $this->status, 'is_healthy' => $this->healthCheck->is_healthy, 'status_code' => $this->statusCode, 'response_time_ms' => $this->responseTime, 'checked_at' => $this->healthCheck->last_checked_at, ]; } }