<?php

namespace App\Mail;

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

class VerifyEmail extends Mailable
{
    use Queueable, SerializesModels;

    public string $verifyUrl;

    public function __construct(public User $user, string $token)
    {
        $frontendUrl = rtrim(config('app.frontend_url', env('FRONTEND_URL', 'http://localhost:3000')), '/');
        $this->verifyUrl = $frontendUrl . '/verify-email?token=' . $token;
    }

    public function envelope(): Envelope
    {
        return new Envelope(subject: 'Verify Your Email — MEG & MAU');
    }

    public function content(): Content
    {
        return new Content(view: 'emails.verify-email');
    }
}
