<?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
    {
        $table = new HtmlString(view('bydauto::mail.testdrive', ['items' => $this->items])->render());
        return (new MailMessage())
            ->subject("预约试驾线索通知")
            ->line("收到新的试驾预约信息：")
            ->line($table)
            ->line("=====")
            ->salutation("祝，工作愉快！");

        // $text = sprintf("姓名：%s <br>电话：<a href='tel:%s'>%s</a>", $this->model->name, $this->model->mobile, $this->model->mobile);
        // $text = new HtmlString($text);
        // return (new MailMessage())
        //     ->subject("预约试驾线索通知")
        //     ->line("收到一条新的试驾预约信息")
        //     ->line($text)
        //     ->line("=====")
        //     ->salutation("祝，工作愉快！");
    }

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