1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00
invoiceninja/app/Jobs/SendNotificationEmail.php

86 lines
1.8 KiB
PHP
Raw Normal View History

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;
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
{
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;
/**
* @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
*/
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;
$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();
}
$userMailer->sendNotification($this->user, $this->invoice, $this->type, $this->payment, $this->notes);
2017-01-11 14:40:13 +01:00
}
}