PermissionTableSeeder::run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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