akaunting/app/Jobs/Purchase/DuplicateBill.php

41 lines
657 B
PHP
Raw Normal View History

2019-11-16 10:21:14 +03:00
<?php
2019-12-31 15:49:09 +03:00
namespace App\Jobs\Purchase;
2019-11-16 10:21:14 +03:00
use App\Abstracts\Job;
2020-06-26 13:40:19 +03:00
use App\Events\Purchase\BillCreated;
2019-12-31 15:49:09 +03:00
use App\Models\Purchase\Bill;
2019-11-16 10:21:14 +03:00
class DuplicateBill extends Job
{
protected $bill;
2020-06-26 13:40:19 +03:00
protected $clone;
2019-11-16 10:21:14 +03:00
/**
* Create a new job instance.
*
* @param $bill
*/
public function __construct($bill)
{
$this->bill = $bill;
}
/**
* Execute the job.
*
* @return Bill
*/
public function handle()
{
2020-06-26 13:40:19 +03:00
\DB::transaction(function () {
$this->clone = $this->bill->duplicate();
});
event(new BillCreated($this->clone));
return $this->clone;
2019-11-16 10:21:14 +03:00
}
}