Completed
Push — master ( b52d53...c245d9 )
by ARCANEDEV
03:13
created

SetupCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 57
ccs 0
cts 18
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 4 1
A createAdminUser() 0 17 1
1
<?php namespace Arcanesoft\Foundation\Console;
2
3
use Arcanedev\Support\Bases\Command;
4
5
/**
6
 * Class     SetupCommand
7
 *
8
 * @package  Arcanesoft\Foundation\Console
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class SetupCommand extends Command
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Properties
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * The name and signature of the console command.
19
     *
20
     * @var string
21
     */
22
    protected $signature = 'foundation:setup';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = 'Foundation setup command.';
30
31
    /* ------------------------------------------------------------------------------------------------
32
     |  Main Functions
33
     | ------------------------------------------------------------------------------------------------
34
     */
35
    /**
36
     * Execute the console command.
37
     */
38
    public function handle()
39
    {
40
        $this->createAdminUser();
41
    }
42
43
    /* ------------------------------------------------------------------------------------------------
44
     |  Other Functions
45
     | ------------------------------------------------------------------------------------------------
46
     */
47
    /**
48
     * Create an admin user.
49
     */
50
    private function createAdminUser()
51
    {
52
        $user = new \Arcanesoft\Auth\Models\User([
53
            'username'   => 'admin',
54
            'first_name' => 'John',
55
            'last_name'  => 'DOE',
56
            'email'      => env('ADMIN_EMAIL', '[email protected]'),
57
            'password'   => env('ADMIN_PASSWORD', 'password'),
58
        ]);
59
60
        $user->is_admin  = true;
61
        $user->is_active = true;
62
63
        $user->save();
64
65
        $this->info('Admin account created !');
66
    }
67
}
68