<?php

namespace App\Jobs;

use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Mail;
use App\Mail\FinanceBillDraftedEmail;
use DB;

class ProcessFinanceBillDraftedEmails implements ShouldQueue
{
    use Queueable;
	public $mailData;

    /**
     * Create a new job instance.
     */
    public function __construct($mailData)
    {
        $this->mailData=$mailData;
    }

    /**
     * Execute the job.
     */
    public function handle(): void
    {
        $emails=DB::table('users')->pluck('email')->toArray();
				foreach ($emails as $recipient) {
					Mail::to($recipient)->send(new FinanceBillDraftedEmail($this->mailData));
				}
    }
}
