2020-05-28 15:59:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs\Invoice;
|
|
|
|
|
2020-10-26 20:10:04 +01:00
|
|
|
use App\Jobs\Entity\CreateEntityPdf;
|
2020-05-28 15:59:45 +02:00
|
|
|
use App\Models\Invoice;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
|
|
|
class InjectSignature implements ShouldQueue
|
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var App\Models\Invoice
|
|
|
|
*/
|
|
|
|
public $invoice;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $signature;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param Invoice $invoice
|
|
|
|
* @param string $signature
|
2020-05-28 15:59:45 +02:00
|
|
|
*/
|
|
|
|
public function __construct(Invoice $invoice, string $signature)
|
|
|
|
{
|
|
|
|
$this->invoice = $invoice;
|
|
|
|
|
|
|
|
$this->signature = $signature;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$invitation = $this->invoice->invitations->whereNotNull('signature_base64')->first();
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! $invitation) {
|
2020-05-28 15:59:45 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$invitation->signature_base64 = $this->signature;
|
|
|
|
$invitation->save();
|
|
|
|
|
2020-10-26 20:10:04 +01:00
|
|
|
CreateEntityPdf::dispatch($invitation);
|
2020-05-28 15:59:45 +02:00
|
|
|
}
|
|
|
|
}
|