MakeSuperUserCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Pratiksh\Adminetic\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Pratiksh\Adminetic\Services\MakeSuperAdmin;
7
8
class MakeSuperUserCommand extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'make:superadmin';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Command to make super user.';
23
24
    /**
25
     * Create a new command instance.
26
     *
27
     * @return void
28
     */
29
    public function __construct()
30
    {
31
        parent::__construct();
32
    }
33
34
    /**
35
     * Execute the console command.
36
     *
37
     * @return int
38
     */
39
    public function handle()
40
    {
41
        // Authorization Password
42
        $authorization_password = $this->secret('Enter Authorization Password To Continue');
43
44
        if (MakeSuperAdmin::checkAuthorization($authorization_password)) {
45
            $this->info('Authorization Granted.');
46
            // Asking for name
47
            $name = $this->ask('Enter Super Admin Name');
48
            // Asking for Email
49
            $email = $this->ask('Enter Super Admin Email');
50
            // Asking for Password
51
            $password = $this->secret('Enter Super Admin Password');
52
53
            $this->info('Creating Super Admin ......');
54
55
            MakeSuperAdmin::make($name, $email, $password);
56
57
            $this->info('Super Admin Created Successfully');
58
        } else {
59
            $this->error('Authorization password is wrong');
60
        }
61
    }
62
}
63