refactored module commands
This commit is contained in:
53
app/Console/Commands/UninstallModule.php
Normal file
53
app/Console/Commands/UninstallModule.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Abstracts\Commands\Module;
|
||||
|
||||
class UninstallModule extends Module
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'module:uninstall {alias} {company} {locale=en-GB}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Uninstall the specified module.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->prepare();
|
||||
|
||||
if (!$this->getModel()) {
|
||||
$this->info("Module [{$this->alias}] not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
$this->changeRuntime();
|
||||
|
||||
// Delete db
|
||||
$this->model->delete();
|
||||
|
||||
$this->createHistory('uninstalled');
|
||||
|
||||
event(new \App\Events\Module\Uninstalled($this->alias, $this->company_id));
|
||||
|
||||
// Delete files
|
||||
$this->module->delete();
|
||||
|
||||
$this->revertRuntime();
|
||||
|
||||
$this->info("Module [{$this->alias}] uninstalled.");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user