invoiceninja/app/Jobs/SendPushNotification.php

60 lines
1.1 KiB
PHP
Raw Normal View History

2017-01-11 15:40:13 +02:00
<?php
namespace App\Jobs;
use App\Models\Invoice;
use App\Services\PushService;
2017-01-30 21:40:43 +02:00
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
2017-01-11 15:40:13 +02:00
/**
2017-01-30 21:40:43 +02:00
* Class SendInvoiceEmail.
2017-01-11 15:40:13 +02:00
*/
class SendPushNotification extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
/**
* @var Invoice
*/
protected $invoice;
/**
* @var string
*/
protected $type;
2017-05-04 20:08:27 +03:00
/**
* @var string
*/
protected $server;
2017-01-11 15:40:13 +02:00
/**
* Create a new job instance.
* @param Invoice $invoice
2017-01-30 21:49:42 +02:00
* @param mixed $type
2017-01-11 15:40:13 +02:00
*/
public function __construct($invoice, $type)
{
$this->invoice = $invoice;
$this->type = $type;
2017-05-04 20:08:27 +03:00
$this->server = config('database.default');
2017-01-11 15:40:13 +02:00
}
/**
* Execute the job.
*
* @param PushService $pushService
*/
public function handle(PushService $pushService)
{
2017-05-29 18:54:37 +03:00
if (config('queue.default') !== 'sync') {
$this->invoice->account->loadLocalizationSettings();
}
2017-01-11 15:40:13 +02:00
$pushService->sendNotification($this->invoice, $this->type);
}
}