-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
delete dashboard/report after module uninstall
- Loading branch information
1 parent
9a82779
commit 72bf03e
Showing
10 changed files
with
191 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace App\Listeners\Module; | ||
|
||
use App\Events\Module\Uninstalled as Event; | ||
use App\Jobs\Common\DeleteDashboard; | ||
use App\Jobs\Common\DeleteReport; | ||
use App\Models\Common\Dashboard; | ||
use App\Models\Common\Report; | ||
use App\Traits\Jobs; | ||
use App\Traits\Relationships; | ||
|
||
class FinishUninstallation | ||
{ | ||
use Jobs, Relationships; | ||
|
||
/** | ||
* Handle the event. | ||
* | ||
* @param Event $event | ||
* @return void | ||
*/ | ||
public function handle(Event $event) | ||
{ | ||
$this->deleteDashboards($event->alias); | ||
$this->deleteReports($event->alias); | ||
} | ||
|
||
/** | ||
* Delete any dashboard created by the module. | ||
* | ||
* @param string $alias | ||
* @return void | ||
*/ | ||
protected function deleteDashboards($alias) | ||
{ | ||
Dashboard::alias($alias)->get()->each(function ($dashboard) { | ||
try { | ||
$this->dispatch(new DeleteDashboard($dashboard)); | ||
} catch (\Exception | \Throwable $e) { | ||
report($e); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Delete any report created by the module. | ||
* | ||
* @param string $alias | ||
* @return void | ||
*/ | ||
protected function deleteReports($alias) | ||
{ | ||
Report::alias($alias)->get()->each(function ($report) { | ||
try { | ||
$this->dispatch(new DeleteReport($report)); | ||
} catch (\Exception | \Throwable $e) { | ||
report($e); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters