<?php

namespace BYDAuto\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\HtmlString;

class TestdirveNotification extends Notification
{
    use Queueable;

    public function __construct(protected $items) {}

    public function via(object $notifiable): array
    {
        return ['mail'];
    }

    public function toMail(object $notifiable): MailMessage
    {
        info('===== TestdirveNotification::toMail', ['items' => $this->items]);
        $table = new HtmlString(view('bydauto::mail.testdrive', ['items' => $this->items])->render());
        return (new MailMessage())
            ->subject("预约试驾线索通知")
            ->line("收到新的试驾预约信息：")
            ->line($table)
            ->salutation(" ");
    }

    public function toArray(object $notifiable): array
    {
        return [];
    }
}
