<?php

namespace App\Mail;

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

class VerifyEmail extends Mailable
{
    use Queueable, SerializesModels;

    public array $payload;

    public function __construct(array $payload)
    {
        $this->payload = $payload;
    }

    public function build()
    {
        return $this
            ->subject($this->payload['subject'] ?? 'Your OTP Code')
            ->view('emails.verify')
            ->with([
                'name' => $this->payload['name'] ?? 'User',
                'otp' => $this->payload['otp'] ?? '',
                'data' => $this->payload['data'] ?? [],
            ]);
    }
}