<?php

namespace App\Mail;

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

class EmailVerificationCode extends Mailable
{
    use Queueable, SerializesModels;

    public $code;
    public $purpose;

    public function __construct($code, $purpose = 'verification')
    {
        $this->code = $code;
        $this->purpose = $purpose;
    }

    public function build()
    {
        $subject = $this->purpose === 'password_reset' ? 'Kode OTP Reset Password' : 'Kode Verifikasi Email';
        return $this->subject($subject)->view('emails.verification_code');
    }
}
