ldc-portsalaries/app/Jobs/SendEmployeeLockedDownMailToSiteRH.php
2021-06-07 18:28:25 +02:00

50 lines
1.2 KiB
PHP

<?php
namespace App\Jobs;
use App\Models\Employee;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
class SendEmployeeLockedDownMailToSiteRH implements ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
/** @var Mailable */
protected $mail;
/** @var Employee */
protected $employee;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(Mailable $mail, Employee $employee)
{
$this->mail = $mail;
$this->employee = $employee;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
Mail::to(['email' => $this->employee->site->email_contact])->send($this->mail);
Log::debug(sprintf('Sent %s to %s', get_class($this->mail), $this->employee->site->email_contact));
}
}