<?php

namespace App\Mail;

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;
use App\Models\Newsletter;
use Illuminate\Support\Facades\URL;

class NewsletterMail extends Mailable
{
    use Queueable, SerializesModels;

    public $unsubscribeUrl;
    public $newsletter;
    public $content;

    public function __construct(Newsletter $newsletter, $content)
    {
        $this->newsletter = $newsletter;
        $this->content = $content;
        $this->unsubscribeUrl = URL::signedRoute('unsubscribe', ['newsletter' => $newsletter->email]);
    }

    public function build()
    {
        return $this->view('emails.newsletter')
                    ->subject('Our Newsletter');
    }

    public function attachments(): array
    {
        return [];
    }
}
