*/ 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 === 'closed' ? "TCP Port {$this->tcpPort->port} is Closed" : "TCP Port {$this->tcpPort->port} is Now Open"; $message = (new MailMessage) ->subject($subject) ->line("Port monitoring alert for {$this->tcpPort->site->name}"); if ($this->status === 'closed') { $message->error() ->line("Port {$this->tcpPort->display_name} ({$this->tcpPort->port}) is currently closed.") ->line("This could indicate a service outage or firewall issue."); } else { $message->success() ->line("Port {$this->tcpPort->display_name} ({$this->tcpPort->port}) is now accessible.") ->line("The service has been restored."); } return $message ->line("Site: {$this->tcpPort->site->url}") ->line("Checked at: {$this->tcpPort->last_checked_at->format('Y-m-d H:i:s')}") ->action('View Details', url("/sites/{$this->tcpPort->site_id}")); } /** * Get the array representation of the notification. * * @return array */ public function toArray(object $notifiable): array { return [ 'type' => 'tcp_port', 'tcp_port_id' => $this->tcpPort->id, 'site_id' => $this->tcpPort->site_id, 'site_name' => $this->tcpPort->site->name, 'port' => $this->tcpPort->port, 'port_name' => $this->tcpPort->display_name, 'status' => $this->status, 'is_open' => $this->tcpPort->is_open, 'checked_at' => $this->tcpPort->last_checked_at, ]; } }