Completed
Push — master ( 3c59f9...34cc61 )
by ARCANEDEV
03:16
created

PermissionTableSeeder::getPasswordResetsSeeds()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

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