<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class TemplateMail extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    public function __construct(
        public string $subjectText,
        public string $viewName,
        public array $payload = []
    ) {}

    public function build()
    {
        return $this->subject($this->subjectText)
            ->view($this->viewName, $this->payload);
    }
}
