Completed
Push — master ( ad6735...e5e602 )
by ARCANEDEV
05:41
created

PermissionTableSeeder::getOtherSeeds()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
ccs 0
cts 0
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php namespace Arcanesoft\Auth\Seeds\Foundation;
2
3
use Arcanesoft\Auth\Policies\DashboardPolicy;
4
use Arcanesoft\Auth\Policies\PermissionsPolicy;
5
use Arcanesoft\Auth\Policies\RolesPolicy;
6
use Arcanesoft\Auth\Policies\UsersPolicy;
7
use Arcanesoft\Auth\Seeds\PermissionsSeeder;
8
9
/**
10
 * Class     PermissionTableSeeder
11
 *
12
 * @package  Arcanesoft\Auth\Seeds\Foundation
13
 * @author   ARCANEDEV <[email protected]>
14
 */
15
class PermissionTableSeeder extends PermissionsSeeder
16
{
17
    /* ------------------------------------------------------------------------------------------------
18
     |  Main Functions
19
     | ------------------------------------------------------------------------------------------------
20
     */
21
    /**
22
     * Run the database seeds.
23
     */
24
    public function run()
25
    {
26
        $this->seed([
27
            [
28
                'group'       => [
29
                    'name'        => 'Auth',
30
                    'slug'        => 'auth',
31
                    'description' => 'Auth permissions group',
32
                ],
33
                'permissions' => array_merge(
34
                    $this->getDashboardSeeds(),
35
                    $this->getUsersSeeds(),
36
                    $this->getRolesSeeds(),
37
                    $this->getPermissionsSeeds()
38
                ),
39
            ],
40
        ]);
41
    }
42
43
    /* ------------------------------------------------------------------------------------------------
44
     |  Other Functions
45
     | ------------------------------------------------------------------------------------------------
46
     */
47
    /**
48
     * Get the other permissions seeds for auth module.
49
     *
50
     * @return array
51
     */
52
    private function getDashboardSeeds()
53
    {
54
        return [
55
            [
56
                'name'        => 'Dashboard - View the dashboard stats',
57
                'description' => 'Allow to view a auth stats.',
58
                'slug'        => DashboardPolicy::PERMISSION_STATS,
59
            ],
60
        ];
61
    }
62
63
    /**
64
     * Get user's permissions seeds.
65
     *
66
     * @return array
67
     */
68
    private function getUsersSeeds()
69
    {
70
        return [
71
            [
72
                'name'        => 'Users - List all users',
73
                'description' => 'Allow to list all users.',
74
                'slug'        => UsersPolicy::PERMISSION_LIST,
75
            ],
76
            [
77
                'name'        => 'Users - View a user',
78
                'description' => 'Allow to view a user\'s details.',
79
                'slug'        => UsersPolicy::PERMISSION_SHOW,
80
            ],
81
            [
82
                'name'        => 'Users - Add/Create a user',
83
                'description' => 'Allow to create a new user.',
84
                'slug'        => UsersPolicy::PERMISSION_CREATE,
85
            ],
86
            [
87
                'name'        => 'Users - Edit/Update a user',
88
                'description' => 'Allow to update a user.',
89
                'slug'        => UsersPolicy::PERMISSION_UPDATE,
90
            ],
91
            [
92
                'name'        => 'Users - Delete a user',
93
                'description' => 'Allow to delete a user.',
94
                'slug'        => UsersPolicy::PERMISSION_DELETE,
95
            ],
96
        ];
97
    }
98
99
    /**
100
     * Get role's permissions seeds.
101
     *
102
     * @return array
103
     */
104
    private function getRolesSeeds()
105
    {
106
        return [
107
            [
108
                'name'        => 'Roles - List all roles',
109
                'description' => 'Allow to list all roles.',
110
                'slug'        => RolesPolicy::PERMISSION_LIST,
111
            ],
112
            [
113
                'name'        => 'Roles - View a role',
114
                'description' => 'Allow to view the role\'s details.',
115
                'slug'        => RolesPolicy::PERMISSION_SHOW,
116
            ],
117
            [
118
                'name'        => 'Roles - Add/Create a role',
119
                'description' => 'Allow to create a new role.',
120
                'slug'        => RolesPolicy::PERMISSION_CREATE,
121
            ],
122
            [
123
                'name'        => 'Roles - Edit/Update a role',
124
                'description' => 'Allow to update a role.',
125
                'slug'        => RolesPolicy::PERMISSION_UPDATE,
126
            ],
127
            [
128
                'name'        => 'Roles - Delete a role',
129
                'description' => 'Allow to delete a role.',
130
                'slug'        => RolesPolicy::PERMISSION_DELETE,
131
            ],
132
        ];
133
    }
134
135
    /**
136
     * Get permissions's permissions seeds. (** Inception **)
137
     *
138
     * @return array
139
     */
140
    private function getPermissionsSeeds()
141
    {
142
        return [
143
            [
144
                'name'        => 'Permissions - List all permissions',
145
                'description' => 'Allow to list all permissions.',
146
                'slug'        => PermissionsPolicy::PERMISSION_LIST,
147
            ],
148
            [
149
                'name'        => 'Permissions - View a permission',
150
                'description' => 'Allow to view the permission\'s details.',
151
                'slug'        => PermissionsPolicy::PERMISSION_SHOW,
152
            ],
153
            [
154
                'name'        => 'Permissions - Update a permission',
155
                'description' => 'Allow to update a permission.',
156
                'slug'        => PermissionsPolicy::PERMISSION_UPDATE,
157
            ],
158
        ];
159
    }
160
}
161