akaunting/app/Jobs/Purchase/DuplicateBill.php

44 lines
839 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;
2019-12-31 15:49:09 +03:00
use App\Models\Purchase\Bill;
use App\Models\Purchase\BillHistory;
2019-11-16 10:21:14 +03:00
class DuplicateBill extends Job
{
protected $bill;
/**
* Create a new job instance.
*
* @param $bill
*/
public function __construct($bill)
{
$this->bill = $bill;
}
/**
* Execute the job.
*
* @return Bill
*/
public function handle()
{
$clone = $this->bill->duplicate();
// Add bill history
BillHistory::create([
'company_id' => session('company_id'),
'bill_id' => $clone->id,
'status_code' => 'draft',
'notify' => 0,
'description' => trans('messages.success.added', ['type' => $clone->bill_number]),
]);
return $clone;
}
}