refactored module commands

This commit is contained in:
Denis Duliçi
2020-06-11 23:32:13 +03:00
parent 72cfdf14b2
commit b54c9b1ecc
16 changed files with 395 additions and 353 deletions

View 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.");
}
}