<?php

namespace App\Mail;

use App\Models\EmailSubscriber;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class SubscriptionConfirmationMail extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    public function __construct(public EmailSubscriber $subscriber) {}

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Confirm Your Newsletter Subscription',
        );
    }

    public function content(): Content
    {
        return new Content(
            view: 'emails.subscription.confirmation',
            with: [
                'subscriber'       => $this->subscriber,
                'confirmationUrl'  => route('subscribe.confirm', $this->subscriber->confirmation_token),
                'unsubscribeUrl'   => route('unsubscribe', $this->subscriber->confirmation_token),
            ],
        );
    }
}
