channels('order_received'); } public function toMail(object $notifiable): MailMessage { return (new MailMessage()) ->subject($this->subjectLine()) ->view('mail.notifications.woo-order-received', [ 'order' => $this->order, 'store' => $this->store, 'manageUrl' => route('woo.orders.index'), ]); } /** @return array */ public function toArray(object $notifiable): array { $label = $this->store->site_name ?? parse_url($this->store->site_url, PHP_URL_HOST) ?? 'your store'; return [ 'title' => 'New order received', 'message' => "Order #{$this->order->order_number} for {$this->order->totalFormatted()} from {$label}.", 'icon' => 'order', 'milestone' => 'order_received', 'url' => route('woo.orders.index'), 'order_id' => $this->order->id, 'store_id' => $this->store->id, ]; } private function subjectLine(): string { $storeLabel = $this->store->site_name ?? parse_url($this->store->site_url, PHP_URL_HOST) ?? 'WooCommerce store'; return "New order #{$this->order->order_number} — {$storeLabel}"; } /** @return list */ private function channels(string $event): array { $config = (array) config("notifications.woo_events.{$event}", ['mail' => true, 'database' => true]); $channels = []; if ($config['mail'] ?? false) { $channels[] = 'mail'; } if ($config['database'] ?? false) { $channels[] = 'database'; } return $channels ?: ['database']; } }