2017-01-11 14:40:13 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
|
|
use App\Models\Payment;
|
|
|
|
use App\Ninja\Mailers\UserMailer;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
2017-01-30 20:40:43 +01:00
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
2017-08-07 11:38:33 +02:00
|
|
|
use App\Models\Traits\SerialisesDeletedModels;
|
2017-01-11 14:40:13 +01:00
|
|
|
|
|
|
|
/**
|
2017-01-30 20:40:43 +01:00
|
|
|
* Class SendInvoiceEmail.
|
2017-01-11 14:40:13 +01:00
|
|
|
*/
|
|
|
|
class SendNotificationEmail extends Job implements ShouldQueue
|
|
|
|
{
|
2017-08-07 11:38:33 +02:00
|
|
|
use InteractsWithQueue, SerializesModels, SerialisesDeletedModels {
|
|
|
|
SerialisesDeletedModels::getRestoredPropertyValue insteadof SerializesModels;
|
|
|
|
}
|
2017-01-11 14:40:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var User
|
|
|
|
*/
|
|
|
|
protected $user;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Invoice
|
|
|
|
*/
|
|
|
|
protected $invoice;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Payment
|
|
|
|
*/
|
|
|
|
protected $payment;
|
|
|
|
|
2017-04-16 09:06:42 +02:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $notes;
|
|
|
|
|
2017-05-04 19:08:27 +02:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $server;
|
|
|
|
|
2017-01-11 14:40:13 +01:00
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
|
2017-01-30 20:40:43 +01:00
|
|
|
* @param UserMailer $userMailer
|
2017-01-11 14:40:13 +01:00
|
|
|
* @param ContactMailer $contactMailer
|
2017-01-30 20:40:43 +01:00
|
|
|
* @param PushService $pushService
|
2017-01-30 20:49:42 +01:00
|
|
|
* @param mixed $user
|
|
|
|
* @param mixed $invoice
|
|
|
|
* @param mixed $type
|
|
|
|
* @param mixed $payment
|
2017-01-11 14:40:13 +01:00
|
|
|
*/
|
2017-04-16 09:06:42 +02:00
|
|
|
public function __construct($user, $invoice, $type, $payment, $notes)
|
2017-01-11 14:40:13 +01:00
|
|
|
{
|
|
|
|
$this->user = $user;
|
|
|
|
$this->invoice = $invoice;
|
|
|
|
$this->type = $type;
|
|
|
|
$this->payment = $payment;
|
2017-04-16 09:06:42 +02:00
|
|
|
$this->notes = $notes;
|
2017-05-04 19:08:27 +02:00
|
|
|
$this->server = config('database.default');
|
2017-01-11 14:40:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @param ContactMailer $mailer
|
|
|
|
*/
|
|
|
|
public function handle(UserMailer $userMailer)
|
|
|
|
{
|
2017-05-29 17:02:08 +02:00
|
|
|
if (config('queue.default') !== 'sync') {
|
|
|
|
$this->user->account->loadLocalizationSettings();
|
|
|
|
}
|
|
|
|
|
2017-04-16 09:06:42 +02:00
|
|
|
$userMailer->sendNotification($this->user, $this->invoice, $this->type, $this->payment, $this->notes);
|
2017-01-11 14:40:13 +01:00
|
|
|
}
|
|
|
|
}
|