FEATURE #1753: add commands for enablind/disabling modules

This commit is contained in:
Michal Kváček
2017-08-01 22:58:59 +02:00
parent c2502a2355
commit 8c15a63c2a
12 changed files with 252 additions and 21 deletions
@@ -0,0 +1,42 @@
<?php
namespace App\Console\Commands\Modules;
use App\Models\Module;
use Illuminate\Console\Command;
class ModuleMigrate extends Command
{
/**
* The name and signature of the console command.
* @var string
*/
protected $signature = 'module:migrate {module}';
/**
* The console command description.
* @var string
*/
protected $description = 'Run migrations in specified module';
/**
* Execute the console command.
* @return mixed
*/
public function handle()
{
$moduleName = $this->argument('module');
$module = Module::where('static_name', $moduleName)
->firstOrFail();
if ($module->has_submodules) {
$submodules = $module->submodules;
foreach ($submodules as $submodule) {
$this->call('module:migrate', ['module' => $submodule->static_name]);
}
}
$this->line('Migrating ' . $module->static_name);
$this->call('migrate', ['--path' => config('modules.paths.modules').'/'.$moduleName.'/Database']);
}
}