1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00
invoiceninja/app/Jobs/SendNotificationEmail.php

88 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2017-01-11 14:40:13 +01:00
<?php
namespace App\Jobs;
2022-01-02 13:01:07 +01:00
use App\Models\Invoice;
2017-01-11 14:40:13 +01:00
use App\Models\Payment;
2022-01-02 13:01:07 +01:00
use App\Models\Traits\SerialisesDeletedModels;
use App\Models\User;
2017-01-11 14:40:13 +01:00
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-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
{
2022-01-02 13:01:07 +01:00
use InteractsWithQueue;
public $deleteWhenMissingModels = true;
2017-01-11 14:40:13 +01:00
/**
* @var User
*/
2022-01-02 13:01:07 +01:00
public User $user;
2017-01-11 14:40:13 +01:00
/**
* @var Invoice
*/
2022-01-02 13:01:07 +01:00
public Invoice $invoice;
2017-01-11 14:40:13 +01:00
/**
* @var string
*/
2022-01-02 13:01:07 +01:00
public $type;
2017-01-11 14:40:13 +01:00
/**
* @var Payment
*/
2022-01-02 13:01:07 +01:00
public ?Payment $payment;
2017-01-11 14:40:13 +01:00
/**
* @var string
*/
2022-01-02 13:01:07 +01:00
public $notes;
2017-05-04 19:08:27 +02:00
/**
* @var string
*/
2022-01-02 13:01:07 +01:00
public $server;
2017-05-04 19:08:27 +02:00
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
*/
2022-01-02 13:01:07 +01:00
public function __construct(User $user, Invoice $invoice, $type, ?Payment $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
}
}