MakeAdmin::handle()   A
last analyzed

Complexity

Conditions 3
Paths 6

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 6
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
namespace EasyPanel\Commands\UserActions;
4
5
use EasyPanel\Support\Contract\UserProviderFacade;
6
use Illuminate\Console\Command;
7
8
class MakeAdmin extends Command
9
{
10
11
    protected $description = 'Register an new admin';
12
13
    protected $signature = 'panel:add {user} {--s|super : Admin will be a super user}';
14
15
    public function handle()
16
    {
17
        $user = $this->argument('user');
18
        try{
19
            $status = UserProviderFacade::makeAdmin($user, $this->option('super'));
20
            $method = $status['type'] == 'success' ? 'info' : 'warn';
21
22
            $this->$method($status['message']);
23
        } catch (\Exception $exception){
24
            $this->warn("Something went wrong!\nError: ". $exception->getMessage());
25
        }
26
    }
27
28
}
29