delete email templates after module uninstall
#1kxwd3z
This commit is contained in:
@ -6,7 +6,9 @@ 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\Setting\DeleteEmailTemplate;
|
||||
use App\Models\Common\Dashboard;
|
||||
use App\Models\Common\EmailTemplate;
|
||||
use App\Models\Common\Report;
|
||||
use App\Traits\Jobs;
|
||||
use Throwable;
|
||||
@ -24,6 +26,7 @@ class FinishUninstallation
|
||||
public function handle(Event $event)
|
||||
{
|
||||
$this->deleteDashboards($event->alias);
|
||||
$this->deleteEmailTemplates($event->alias);
|
||||
$this->deleteReports($event->alias);
|
||||
}
|
||||
|
||||
@ -48,6 +51,23 @@ class FinishUninstallation
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete any email template created by the module.
|
||||
*
|
||||
* @param string $alias
|
||||
* @return void
|
||||
*/
|
||||
protected function deleteEmailTemplates($alias)
|
||||
{
|
||||
EmailTemplate::moduleAlias($alias)->get()->each(function ($template) {
|
||||
try {
|
||||
$this->dispatch(new DeleteEmailTemplate($template));
|
||||
} catch (Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete any report created by the module.
|
||||
*
|
||||
|
Reference in New Issue
Block a user