<?php

namespace App\Mail;

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

class BroadcastEmail extends Mailable
{
    use Queueable;

    public $title;
    public $content;
    public $image;

    public function __construct($title, $content, $image = null)
    {
        $this->title = $title;
        $this->content = $content;
        $this->image = $image;
    }

    public function build()
    {
        $email = $this->subject($this->title)
                      ->view('emails.broadcast');

        if ($this->image) {
            $email->attach(storage_path('app/public/' . $this->image));
        }

        return $email;
    }
}
