<?php

namespace App\Mail;

use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class LoginOtpMail extends Mailable
{
    use Queueable, SerializesModels;

    public User $user;
    public string $otpCode;

    public function __construct(User $user, string $otpCode)
    {
        $this->user = $user;
        $this->otpCode = $otpCode;
    }

    public function build(): self
    {
        return $this->subject('Your login verification code')
            ->view('emails.login-otp')
            ->with([
                'name' => $this->user->name,
                'otp'  => $this->otpCode,
            ]);
    }
}

