added db transaction to jobs

This commit is contained in:
Denis Duliçi
2020-06-26 13:40:19 +03:00
parent f20f5c9def
commit acdc9da2c8
57 changed files with 606 additions and 469 deletions

View File

@ -14,10 +14,10 @@ class CreateBill extends Job
{
use Currencies, DateTime;
protected $request;
protected $bill;
protected $request;
/**
* Create a new job instance.
*
@ -41,20 +41,22 @@ class CreateBill extends Job
event(new BillCreating($this->request));
$this->bill = Bill::create($this->request->all());
\DB::transaction(function () {
$this->bill = Bill::create($this->request->all());
// Upload attachment
if ($this->request->file('attachment')) {
$media = $this->getMedia($this->request->file('attachment'), 'bills');
// Upload attachment
if ($this->request->file('attachment')) {
$media = $this->getMedia($this->request->file('attachment'), 'bills');
$this->bill->attachMedia($media, 'attachment');
}
$this->bill->attachMedia($media, 'attachment');
}
$this->createItemsAndTotals();
$this->createItemsAndTotals();
$this->bill->update($this->request->input());
$this->bill->update($this->request->input());
$this->bill->createRecurring();
$this->bill->createRecurring();
});
event(new BillCreated($this->bill));