43 lines
992 B
PHP
43 lines
992 B
PHP
<?php
|
|
|
|
namespace App\Jobs\Notification;
|
|
|
|
use App\User;
|
|
use App\Notification;
|
|
use Illuminate\Bus\Queueable;
|
|
use App\Mail\NotificationEmail;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
class SendNotificationEmail implements ShouldQueue
|
|
{
|
|
use InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
protected $user;
|
|
protected $notification;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct(Notification $notification, User $user)
|
|
{
|
|
$this->notification = $notification;
|
|
$this->user = $user;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle()
|
|
{
|
|
Mail::to($this->user->email)->send(new NotificationEmail($this->notification, $this->user));
|
|
$this->notification->incrementNumberOfEmailsSentAndCheckDeletioNStatus();
|
|
}
|
|
}
|