<?php

namespace App\Jobs;

use App\Models\User;
use App\Mail\BroadcastEmail;
use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Mail;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class SendBroadcastEmailJob implements ShouldQueue
{
    use Dispatchable, Queueable;

    protected $user;
    protected $title;
    protected $content;
    protected $image;

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

    public function handle()
    {
        Mail::to($this->user->email)->send(
            new BroadcastEmail($this->title, $this->content, $this->image)
        );
    }
}
