fixed jobs..
This commit is contained in:
parent
554e895496
commit
bf5fc4f363
@ -4,18 +4,18 @@ namespace App\Jobs\Common;
|
|||||||
|
|
||||||
use App\Abstracts\Job;
|
use App\Abstracts\Job;
|
||||||
|
|
||||||
class DeleteItem extends Job
|
class DeleteWidget extends Job
|
||||||
{
|
{
|
||||||
protected $item;
|
protected $widget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* 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()
|
public function handle()
|
||||||
{
|
{
|
||||||
$this->authorize();
|
|
||||||
|
|
||||||
\DB::transaction(function () {
|
\DB::transaction(function () {
|
||||||
$this->deleteRelationships($this->item, ['taxes']);
|
$this->widget->delete();
|
||||||
|
|
||||||
$this->item->delete();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ namespace App\Jobs\Common;
|
|||||||
use App\Abstracts\Job;
|
use App\Abstracts\Job;
|
||||||
use App\Models\Common\Widget;
|
use App\Models\Common\Widget;
|
||||||
|
|
||||||
class UpdateItem extends Job
|
class UpdateWidget extends Job
|
||||||
{
|
{
|
||||||
protected $widget;
|
protected $widget;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user