SeedCommand::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Enomotodev\LaractiveAdmin\Console;
4
5
use Illuminate\Console\Command;
6
use Enomotodev\LaractiveAdmin\AdminUser;
7
8
class SeedCommand extends Command
9
{
10
    /**
11
     * @var string
12
     */
13
    const ADMIN_USER_EMAIL = '[email protected]';
14
15
    /**
16
     * @var string
17
     */
18
    const ADMIN_USER_PASSWORD = 'password';
19
20
    /**
21
     * @var string
22
     */
23
    protected $name = 'laractive-admin:seed';
24
25
    /**
26
     * @var string
27
     */
28
    protected $description = 'Generate seed data';
29
30
    /**
31
     * @return void
32
     */
33 1
    public function handle()
34
    {
35 1
        if (! AdminUser::where('email', '[email protected]')->first()) {
36 1
            AdminUser::create([
37 1
                'email' => self::ADMIN_USER_EMAIL,
38 1
                'password' => \Hash::make(self::ADMIN_USER_PASSWORD),
39
            ]);
40
        }
41
42 1
        $this->info('Generate data successfully!');
43 1
    }
44
}
45