Passed
Push — master ( b831b6...96f132 )
by John
06:04 queued 21s
created

CreateAdminCommand::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 9
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace App\Console\Commands\Manage;
4
5
use Illuminate\Console\Command;
6
7
class CreateAdminCommand extends Command
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'manage:create-admin';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Create a admin user';
22
23
    /**
24
     * Execute the console command.
25
     */
26
    public function handle()
27
    {
28
        $userModel = config('admin.database.users_model');
29
        $username = $this->ask('Please enter a username to login');
30
        $password = bcrypt($this->secret('Please enter a password to login'));
31
        $name = $this->ask('Please enter a name to display');
32
        $user = new $userModel(compact('username', 'password', 'name'));
33
        $user->save();
34
        $this->info("Admin User [$name] created successfully.");
35
    }
36
}
37