| @@ 8-53 (lines=46) @@ | ||
| 5 | use Illuminate\Console\Command; |
|
| 6 | use Symfony\Component\Console\Input\InputArgument; |
|
| 7 | ||
| 8 | class DisableCommand extends Command |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * The console command name. |
|
| 12 | * |
|
| 13 | * @var string |
|
| 14 | */ |
|
| 15 | protected $name = 'module:disable'; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * The console command description. |
|
| 19 | * |
|
| 20 | * @var string |
|
| 21 | */ |
|
| 22 | protected $description = 'Disable the specified module.'; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Execute the console command. |
|
| 26 | */ |
|
| 27 | public function handle() |
|
| 28 | { |
|
| 29 | $module = $this->laravel['modules']->findOrFail($this->argument('module')); |
|
| 30 | ||
| 31 | if ($module->enabled()) { |
|
| 32 | $module->disable(); |
|
| 33 | ||
| 34 | $this->info("Module [{$module}] disabled successful."); |
|
| 35 | } else { |
|
| 36 | $this->comment("Module [{$module}] has already disabled."); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Get the console command arguments. |
|
| 42 | * |
|
| 43 | * @return array |
|
| 44 | */ |
|
| 45 | protected function getArguments() |
|
| 46 | { |
|
| 47 | return [ |
|
| 48 | ['module', InputArgument::REQUIRED, 'Module name.'], |
|
| 49 | ]; |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| @@ 8-53 (lines=46) @@ | ||
| 5 | use Illuminate\Console\Command; |
|
| 6 | use Symfony\Component\Console\Input\InputArgument; |
|
| 7 | ||
| 8 | class EnableCommand extends Command |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * The console command name. |
|
| 12 | * |
|
| 13 | * @var string |
|
| 14 | */ |
|
| 15 | protected $name = 'module:enable'; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * The console command description. |
|
| 19 | * |
|
| 20 | * @var string |
|
| 21 | */ |
|
| 22 | protected $description = 'Enable the specified module.'; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Execute the console command. |
|
| 26 | */ |
|
| 27 | public function handle() |
|
| 28 | { |
|
| 29 | $module = $this->laravel['modules']->findOrFail($this->argument('module')); |
|
| 30 | ||
| 31 | if ($module->disabled()) { |
|
| 32 | $module->enable(); |
|
| 33 | ||
| 34 | $this->info("Module [{$module}] enabled successful."); |
|
| 35 | } else { |
|
| 36 | $this->comment("Module [{$module}] has already enabled."); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * Get the console command arguments. |
|
| 42 | * |
|
| 43 | * @return array |
|
| 44 | */ |
|
| 45 | protected function getArguments() |
|
| 46 | { |
|
| 47 | return [ |
|
| 48 | ['module', InputArgument::REQUIRED, 'Module name.'], |
|
| 49 | ]; |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||