Merge pull request #2791 from CihanSenturk/master
Added delete widget to module uninstall listener
This commit is contained in:
commit
64181dc200
@ -6,9 +6,11 @@ use App\Events\Module\Uninstalled as Event;
|
||||
use App\Exceptions\Common\LastDashboard;
|
||||
use App\Jobs\Common\DeleteDashboard;
|
||||
use App\Jobs\Common\DeleteReport;
|
||||
use App\Jobs\Common\DeleteWidget;
|
||||
use App\Jobs\Setting\DeleteEmailTemplate;
|
||||
use App\Models\Common\Dashboard;
|
||||
use App\Models\Common\Report;
|
||||
use App\Models\Common\Widget;
|
||||
use App\Models\Setting\EmailTemplate;
|
||||
use App\Traits\Jobs;
|
||||
use Throwable;
|
||||
@ -26,6 +28,7 @@ class FinishUninstallation
|
||||
public function handle(Event $event)
|
||||
{
|
||||
$this->deleteDashboards($event->alias);
|
||||
$this->deleteWidgets($event->alias);
|
||||
$this->deleteEmailTemplates($event->alias);
|
||||
$this->deleteReports($event->alias);
|
||||
}
|
||||
@ -51,6 +54,23 @@ class FinishUninstallation
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete any widget created by the module.
|
||||
*
|
||||
* @param string $alias
|
||||
* @return void
|
||||
*/
|
||||
protected function deleteWidgets($alias)
|
||||
{
|
||||
Widget::alias($alias)->get()->each(function ($widget) {
|
||||
try {
|
||||
$this->dispatch(new DeleteWidget($widget));
|
||||
} catch (Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete any email template created by the module.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user