added db transaction to jobs
This commit is contained in:
@ -7,6 +7,8 @@ use App\Models\Setting\Category;
|
||||
|
||||
class CreateCategory extends Job
|
||||
{
|
||||
protected $category;
|
||||
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
@ -26,8 +28,10 @@ class CreateCategory extends Job
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$category = Category::create($this->request->all());
|
||||
\DB::transaction(function () {
|
||||
$this->category = Category::create($this->request->all());
|
||||
});
|
||||
|
||||
return $category;
|
||||
return $this->category;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ use App\Models\Setting\Currency;
|
||||
|
||||
class CreateCurrency extends Job
|
||||
{
|
||||
protected $currency;
|
||||
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
@ -31,14 +33,16 @@ class CreateCurrency extends Job
|
||||
$this->request['rate'] = '1';
|
||||
}
|
||||
|
||||
$currency = Currency::create($this->request->all());
|
||||
\DB::transaction(function () {
|
||||
$this->currency = Currency::create($this->request->all());
|
||||
|
||||
// Update default currency setting
|
||||
if ($this->request->get('default_currency')) {
|
||||
setting()->set('default.currency', $this->request->get('code'));
|
||||
setting()->save();
|
||||
}
|
||||
// Update default currency setting
|
||||
if ($this->request->get('default_currency')) {
|
||||
setting()->set('default.currency', $this->request->get('code'));
|
||||
setting()->save();
|
||||
}
|
||||
});
|
||||
|
||||
return $currency;
|
||||
return $this->currency;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ use App\Models\Setting\Tax;
|
||||
|
||||
class CreateTax extends Job
|
||||
{
|
||||
protected $tax;
|
||||
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
@ -26,8 +28,10 @@ class CreateTax extends Job
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$tax = Tax::create($this->request->all());
|
||||
\DB::transaction(function () {
|
||||
$this->tax = Tax::create($this->request->all());
|
||||
});
|
||||
|
||||
return $tax;
|
||||
return $this->tax;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,9 @@ class DeleteCategory extends Job
|
||||
{
|
||||
$this->authorize();
|
||||
|
||||
$this->category->delete();
|
||||
\DB::transaction(function () {
|
||||
$this->category->delete();
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -27,7 +27,9 @@ class DeleteCurrency extends Job
|
||||
{
|
||||
$this->authorize();
|
||||
|
||||
$this->currency->delete();
|
||||
\DB::transaction(function () {
|
||||
$this->currency->delete();
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -27,7 +27,9 @@ class DeleteTax extends Job
|
||||
{
|
||||
$this->authorize();
|
||||
|
||||
$this->tax->delete();
|
||||
\DB::transaction(function () {
|
||||
$this->tax->delete();
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -32,7 +32,9 @@ class UpdateCategory extends Job
|
||||
{
|
||||
$this->authorize();
|
||||
|
||||
$this->category->update($this->request->all());
|
||||
\DB::transaction(function () {
|
||||
$this->category->update($this->request->all());
|
||||
});
|
||||
|
||||
return $this->category;
|
||||
}
|
||||
|
@ -37,13 +37,15 @@ class UpdateCurrency extends Job
|
||||
$this->request['rate'] = '1';
|
||||
}
|
||||
|
||||
$this->currency->update($this->request->all());
|
||||
\DB::transaction(function () {
|
||||
$this->currency->update($this->request->all());
|
||||
|
||||
// Update default currency setting
|
||||
if ($this->request->get('default_currency')) {
|
||||
setting()->set('default.currency', $this->request->get('code'));
|
||||
setting()->save();
|
||||
}
|
||||
// Update default currency setting
|
||||
if ($this->request->get('default_currency')) {
|
||||
setting()->set('default.currency', $this->request->get('code'));
|
||||
setting()->save();
|
||||
}
|
||||
});
|
||||
|
||||
return $this->currency;
|
||||
}
|
||||
|
@ -32,7 +32,9 @@ class UpdateTax extends Job
|
||||
{
|
||||
$this->authorize();
|
||||
|
||||
$this->tax->update($this->request->all());
|
||||
\DB::transaction(function () {
|
||||
$this->tax->update($this->request->all());
|
||||
});
|
||||
|
||||
return $this->tax;
|
||||
}
|
||||
|
Reference in New Issue
Block a user