akaunting/app/Jobs/Purchase/DuplicateBill.php
2020-06-26 13:40:19 +03:00

41 lines
657 B
PHP

<?php
namespace App\Jobs\Purchase;
use App\Abstracts\Job;
use App\Events\Purchase\BillCreated;
use App\Models\Purchase\Bill;
class DuplicateBill extends Job
{
protected $bill;
protected $clone;
/**
* Create a new job instance.
*
* @param $bill
*/
public function __construct($bill)
{
$this->bill = $bill;
}
/**
* Execute the job.
*
* @return Bill
*/
public function handle()
{
\DB::transaction(function () {
$this->clone = $this->bill->duplicate();
});
event(new BillCreated($this->clone));
return $this->clone;
}
}