fixed jobs..

This commit is contained in:
Cüneyt Şentürk 2021-09-04 16:08:13 +03:00
parent 554e895496
commit bf5fc4f363
2 changed files with 7 additions and 35 deletions

View File

@ -4,18 +4,18 @@ namespace App\Jobs\Common;
use App\Abstracts\Job;
class DeleteItem extends Job
class DeleteWidget extends Job
{
protected $item;
protected $widget;
/**
* Create a new job instance.
*
* @param $item
* @param $widget
*/
public function __construct($item)
public function __construct($widget)
{
$this->item = $item;
$this->widget = $widget;
}
/**
@ -25,38 +25,10 @@ class DeleteItem extends Job
*/
public function handle()
{
$this->authorize();
\DB::transaction(function () {
$this->deleteRelationships($this->item, ['taxes']);
$this->item->delete();
$this->widget->delete();
});
return true;
}
/**
* Determine if this action is applicable.
*
* @return void
*/
public function authorize()
{
if ($relationships = $this->getRelationships()) {
$message = trans('messages.warning.deleted', ['name' => $this->item->name, 'text' => implode(', ', $relationships)]);
throw new \Exception($message);
}
}
public function getRelationships()
{
$rels = [
'invoice_items' => 'invoices',
'bill_items' => 'bills',
];
return $this->countRelationships($this->item, $rels);
}
}

View File

@ -5,7 +5,7 @@ namespace App\Jobs\Common;
use App\Abstracts\Job;
use App\Models\Common\Widget;
class UpdateItem extends Job
class UpdateWidget extends Job
{
protected $widget;