RoleSeeder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php namespace Anomaly\UsersModule\Role;
2
3
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
4
use Anomaly\UsersModule\Role\Contract\RoleRepositoryInterface;
5
6
/**
7
 * Class RoleSeeder
8
 *
9
 * @link          http://pyrocms.com/
10
 * @author        PyroCMS, Inc. <[email protected]>
11
 * @author        Ryan Thompson <[email protected]>
12
 */
13
class RoleSeeder extends Seeder
14
{
15
16
    /**
17
     * The role repository.
18
     *
19
     * @var RoleRepositoryInterface
20
     */
21
    protected $roles;
22
23
    /**
24
     * Create a new RoleSeeder instance.
25
     *
26
     * @param RoleRepositoryInterface $roles
27
     */
28
    public function __construct(RoleRepositoryInterface $roles)
29
    {
30
        $this->roles = $roles;
31
    }
32
33
    /**
34
     * Run the seeder.
35
     */
36
    public function run()
37
    {
38
        $this->roles->truncate();
39
40
        $this->roles->create(
41
            [
42
                'en'   => [
43
                    'name'        => 'Admin',
44
                    'description' => 'The super admin role.',
45
                ],
46
                'slug' => 'admin',
47
            ]
48
        );
49
50
        $this->roles->create(
51
            [
52
                'en'   => [
53
                    'name'        => 'User',
54
                    'description' => 'The default user role.',
55
                ],
56
                'slug' => 'user',
57
            ]
58
        );
59
60
        $this->roles->create(
61
            [
62
                'en'   => [
63
                    'name'        => 'Guest',
64
                    'description' => 'The fallback role for non-users.',
65
                ],
66
                'slug' => 'guest',
67
            ]
68
        );
69
    }
70
}
71