akaunting/app/Jobs/Sale/CancelInvoice.php

41 lines
716 B
PHP
Raw Normal View History

2020-03-28 17:54:36 +03:00
<?php
namespace App\Jobs\Sale;
use App\Abstracts\Job;
use App\Models\Sale\Invoice;
class CancelInvoice extends Job
{
protected $invoice;
/**
* Create a new job instance.
*
* @param $invoice
*/
public function __construct($invoice)
{
$this->invoice = $invoice;
}
/**
* Execute the job.
*
* @return Invoice
*/
public function handle()
{
2020-06-26 13:40:19 +03:00
\DB::transaction(function () {
$this->deleteRelationships($this->invoice, [
'transactions', 'recurring'
]);
2020-03-28 17:54:36 +03:00
2020-06-26 13:40:19 +03:00
$this->invoice->status = 'cancelled';
$this->invoice->save();
});
2020-03-28 17:54:36 +03:00
2020-03-28 22:50:06 +03:00
return $this->invoice;
2020-03-28 17:54:36 +03:00
}
}