*/ 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 === 'invalid' ? "DNS Record Invalid: {$this->dnsRecord->domain}" : "DNS Record Restored: {$this->dnsRecord->domain}"; $message = (new MailMessage) ->subject($subject); if ($this->status === 'invalid') { $message->error() ->line("DNS record validation failed for {$this->dnsRecord->record_type} record of {$this->dnsRecord->domain}") ->line("This could indicate a DNS configuration issue or propagation delay."); if ($this->errorMessage) { $message->line("Error: {$this->errorMessage}"); } elseif ($this->actualValue && $this->dnsRecord->expected_value) { $actualFormatted = is_array($this->actualValue) ? implode(', ', $this->actualValue) : $this->actualValue; $message->line("Expected: {$this->dnsRecord->expected_value}") ->line("Actual: {$actualFormatted}"); } } else { $message->success() ->line("DNS record for {$this->dnsRecord->record_type} of {$this->dnsRecord->domain} is now valid.") ->line("The DNS configuration has been restored."); if ($this->actualValue) { $actualFormatted = is_array($this->actualValue) ? implode(', ', $this->actualValue) : $this->actualValue; $message->line("Current value: {$actualFormatted}"); } } return $message ->line("Domain: {$this->dnsRecord->domain}") ->line("Record Type: {$this->dnsRecord->record_type}") ->line("Checked at: {$this->dnsRecord->last_checked_at->format('Y-m-d H:i:s')}") ->action('View Details', url("/sites/{$this->dnsRecord->site_id}/dns-records/{$this->dnsRecord->id}")); } /** * Get the array representation of the notification. * * @return array */ public function toArray(object $notifiable): array { return [ 'type' => 'dns_record', 'dns_record_id' => $this->dnsRecord->id, 'site_id' => $this->dnsRecord->site_id, 'site_name' => $this->dnsRecord->site->name, 'domain' => $this->dnsRecord->domain, 'record_type' => $this->dnsRecord->record_type, 'status' => $this->status, 'is_valid' => $this->dnsRecord->is_valid, 'expected_value' => $this->dnsRecord->expected_value, 'actual_value' => $this->actualValue, 'error_message' => $this->errorMessage, 'checked_at' => $this->dnsRecord->last_checked_at, ]; } }