Passed
Push — dev6 ( 273503...6464e0 )
by Ron
20:01
created

DisableModuleCommand::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 16
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace App\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Facades\Artisan;
7
use Nwidart\Modules\Facades\Module;
8
9
class DisableModuleCommand extends Command
10
{
11
    protected $signature  = 'tb_module:disable {module}';
12
    protected $description = 'Disable, but do not remove a Tech Bench Add On Module';
13
14
    /**
15
     * Create a new command instance
16
     */
17
    public function __construct()
18
    {
19
        parent::__construct();
20
    }
21
22
    /**
23
     * Execute the console command
24
     */
25
    public function handle()
26
    {
27
        $this->module = Module::find($this->argument('module'));
0 ignored issues
show
Bug Best Practice introduced by
The property module does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
28
29
        //  Verify Module exists
30
        if(!$this->module)
31
        {
32
            $this->error('Unable to find module');
33
            return 1;
34
        }
35
36
        Artisan::call('module:disable '.$this->module->getStudlyName());
37
38
        $this->info('Module has been disabled');
39
40
        return Command::SUCCESS;
41
    }
42
}
43