Completed
Push — master ( 394917...1d96a4 )
by ARCANEDEV
08:06
created

UserTableSeeder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
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 39
ccs 0
cts 19
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 4 1
A seedAdminUser() 0 17 1
1
<?php namespace Arcanesoft\Auth\Seeds\Foundation;
2
3
use Arcanesoft\Auth\Bases\Seeder;
4
use Arcanesoft\Auth\Models\Role;
5
use Arcanesoft\Auth\Models\User;
6
7
/**
8
 * Class     UserTableSeeder
9
 *
10
 * @package  Arcanesoft\Auth\Seeds\Foundation
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class UserTableSeeder extends Seeder
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Main Functions
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * Run the database seeds.
21
     */
22
    public function run()
23
    {
24
        $this->seedAdminUser();
25
    }
26
27
    /* ------------------------------------------------------------------------------------------------
28
     |  Other Functions
29
     | ------------------------------------------------------------------------------------------------
30
     */
31
    /**
32
     * Seed the admin account.
33
     */
34
    private function seedAdminUser()
35
    {
36
        $adminRole = Role::where('slug', 'administrator')->first();
37
        $adminUser = new User([
38
            'username'   => 'admin',
39
            'first_name' => 'Super',
40
            'last_name'  => 'ADMIN',
41
            'email'      => env('ADMIN_EMAIL',    '[email protected]'),
42
            'password'   => env('ADMIN_PASSWORD', 'password'),
43
        ]);
44
45
        $adminUser->is_admin  = true;
46
        $adminUser->is_active = true;
47
48
        $adminUser->save();
49
        $adminUser->attachRole($adminRole);
50
    }
51
}
52