1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00
invoiceninja/app/Jobs/SendPushNotification.php

60 lines
1.1 KiB
PHP
Raw Normal View History

2017-01-11 14:40:13 +01:00
<?php
namespace App\Jobs;
use App\Models\Invoice;
use App\Services\PushService;
2017-01-30 20:40:43 +01:00
use Illuminate\Contracts\Queue\ShouldQueue;
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 SendPushNotification extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
/**
* @var Invoice
*/
protected $invoice;
/**
* @var string
*/
protected $type;
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.
* @param Invoice $invoice
2017-01-30 20:49:42 +01:00
* @param mixed $type
2017-01-11 14:40:13 +01:00
*/
public function __construct($invoice, $type)
{
$this->invoice = $invoice;
$this->type = $type;
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 PushService $pushService
*/
public function handle(PushService $pushService)
{
2017-05-29 17:54:37 +02:00
if (config('queue.default') !== 'sync') {
$this->invoice->account->loadLocalizationSettings();
}
2017-01-11 14:40:13 +01:00
$pushService->sendNotification($this->invoice, $this->type);
}
}