<?php
namespace App\Mail;

use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class AppMailer extends Mailable
{
    use SerializesModels;

    public string $slug;
    public array $data;
    public string $subjectLine;

    public function __construct(string $slug, array $data, string $subjectLine)
    {
        $this->slug = $slug;
        $this->data = $data;
        $this->subjectLine = $subjectLine;
    }

    public function build()
    {
        return $this->subject($this->subjectLine)
            ->view("emails.types.{$this->slug}")
            ->with($this->data);
    }
}
