MakeAdmin   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 3
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