Completed
Push — master ( 248e12...0fb364 )
by ARCANEDEV
03:19
created

RoleTableSeeder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 59
ccs 0
cts 29
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 16 1
A seed() 0 6 2
A createRole() 0 9 1
1
<?php namespace Arcanesoft\Auth\Seeds\Foundation;
2
3
use Arcanesoft\Auth\Bases\Seeder;
4
use Arcanesoft\Auth\Models\Role;
5
6
/**
7
 * Class     RoleTableSeeder
8
 *
9
 * @package  Arcanesoft\Auth\Seeds\Foundation
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class RoleTableSeeder extends Seeder
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Main Functions
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * Run the database seeds.
20
     */
21
    public function run()
22
    {
23
        $this->seed([
24
            [
25
                'name'        => 'Administrator',
26
                'description' => 'The system administrator role.',
27
                'is_active'   => true,
28
                'is_locked'   => true,
29
            ],[
30
                'name'        => 'Member',
31
                'description' => 'The member role.',
32
                'is_active'   => true,
33
                'is_locked'   => true,
34
            ]
35
        ]);
36
    }
37
38
    /* ------------------------------------------------------------------------------------------------
39
     |  Other Functions
40
     | ------------------------------------------------------------------------------------------------
41
     */
42
    /**
43
     * Seed roles.
44
     *
45
     * @param  array  $roles
46
     */
47
    protected function seed(array $roles)
48
    {
49
        foreach ($roles as $data) {
50
            $this->createRole($data);
51
        }
52
    }
53
54
    /**
55
     * Create a role.
56
     *
57
     * @param  array  $data
58
     *
59
     * @return bool
60
     */
61
    protected function createRole(array $data)
62
    {
63
        $role = new Role($data);
64
65
        $role->is_active = $data['is_active'];
66
        $role->is_locked = $data['is_locked'];
67
68
        return $role->save();
69
    }
70
}
71