Completed
Push — master ( 3a2fd6...5b4baf )
by ARCANEDEV
04:23
created

PermissionsTableSeeder::getDashboardSeeds()   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 10
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php namespace Arcanesoft\Blog\Seeds;
2
3
use Arcanesoft\Auth\Seeds\PermissionsSeeder;
4
use Arcanesoft\Blog\Policies\CategoriesPolicy;
5
use Arcanesoft\Blog\Policies\PostsPolicy;
6
use Arcanesoft\Blog\Policies\TagsPolicy;
7
8
/**
9
 * Class     PermissionsTableSeeder
10
 *
11
 * @package  Arcanesoft\Blog\Seeds
12
 * @author   ARCANEDEV <[email protected]>
13
 */
14
class PermissionsTableSeeder extends PermissionsSeeder
15
{
16
    /* -----------------------------------------------------------------
17
     |  Main Methods
18
     | -----------------------------------------------------------------
19
     */
20
21
    /**
22
     * Run the database seeds.
23
     */
24
    public function run()
25
    {
26
        $this->seed([
27
            [
28
                'group'       => [
29
                    'name'        => 'Blog',
30
                    'slug'        => 'blog',
31
                    'description' => 'Blog permissions group',
32
                ],
33
                'permissions' => array_merge(
34
                    $this->getDashboardSeeds(),
35
                    $this->getPostsSeeds(),
36
                    $this->getCategoriesSeeds(),
37
                    $this->getTagsSeeds()
38
                ),
39
            ],
40
        ]);
41
    }
42
43
    /* -----------------------------------------------------------------
44
     |  Other Methods
45
     | -----------------------------------------------------------------
46
     */
47
48
    /**
49
     * Get the dashboard permissions
50
     *
51
     * @return array
52
     */
53
    private function getDashboardSeeds()
54
    {
55
        return [
56
            [
57
                'name'        => 'Statistics - Show all the stats',
58
                'description' => 'Show all the blog stats.',
59
                'slug'        => PostsPolicy::PERMISSION_LIST,
60
            ],
61
        ];
62
    }
63
64
    /**
65
     * Get the Posts permissions.
66
     *
67
     * @return array
68
     */
69
    private function getPostsSeeds()
70
    {
71
        return [
72
            [
73
                'name'        => 'Posts - List all posts',
74
                'description' => 'Allow to list all posts.',
75
                'slug'        => PostsPolicy::PERMISSION_LIST,
76
            ],
77
            [
78
                'name'        => 'Posts - View a post',
79
                'description' => 'Allow to display a post.',
80
                'slug'        => PostsPolicy::PERMISSION_SHOW,
81
            ],
82
            [
83
                'name'        => 'Posts - Create a post',
84
                'description' => 'Allow to create a post.',
85
                'slug'        => PostsPolicy::PERMISSION_CREATE,
86
            ],
87
            [
88
                'name'        => 'Posts - Update a post',
89
                'description' => 'Allow to update a post.',
90
                'slug'        => PostsPolicy::PERMISSION_UPDATE,
91
            ],
92
            [
93
                'name'        => 'Posts - Delete a post',
94
                'description' => 'Allow to delete a post.',
95
                'slug'        => PostsPolicy::PERMISSION_DELETE,
96
            ],
97
        ];
98
    }
99
100
    /**
101
     * Get the Categories permissions.
102
     *
103
     * @return array
104
     */
105
    private function getCategoriesSeeds()
106
    {
107
        return [
108
            [
109
                'name'        => 'Categories - List all posts',
110
                'description' => 'Allow to list all categories.',
111
                'slug'        => CategoriesPolicy::PERMISSION_LIST,
112
            ],
113
            [
114
                'name'        => 'Categories - View a category',
115
                'description' => 'Allow to display a category.',
116
                'slug'        => CategoriesPolicy::PERMISSION_SHOW,
117
            ],
118
            [
119
                'name'        => 'Categories - Create a category',
120
                'description' => 'Allow to create a category.',
121
                'slug'        => CategoriesPolicy::PERMISSION_CREATE,
122
            ],
123
            [
124
                'name'        => 'Categories - Update a category',
125
                'description' => 'Allow to update a category.',
126
                'slug'        => CategoriesPolicy::PERMISSION_UPDATE,
127
            ],
128
            [
129
                'name'        => 'Categories - Delete a category',
130
                'description' => 'Allow to delete a category.',
131
                'slug'        => CategoriesPolicy::PERMISSION_DELETE,
132
            ],
133
        ];
134
    }
135
136
    /**
137
     * Get the Tags permissions.
138
     *
139
     * @return array
140
     */
141
    private function getTagsSeeds()
142
    {
143
        return [
144
            [
145
                'name'        => 'Tags - List all tags',
146
                'description' => 'Allow to list all tags.',
147
                'slug'        => TagsPolicy::PERMISSION_LIST,
148
            ],
149
            [
150
                'name'        => 'Tags - View a tag',
151
                'description' => 'Allow to display a tag.',
152
                'slug'        => TagsPolicy::PERMISSION_SHOW,
153
            ],
154
            [
155
                'name'        => 'Tags - Create a tag',
156
                'description' => 'Allow to create a tag.',
157
                'slug'        => TagsPolicy::PERMISSION_CREATE,
158
            ],
159
            [
160
                'name'        => 'Tags - Update a tag',
161
                'description' => 'Allow to update a tag.',
162
                'slug'        => TagsPolicy::PERMISSION_UPDATE,
163
            ],
164
            [
165
                'name'        => 'Tags - Delete a tag',
166
                'description' => 'Allow to delete a tag.',
167
                'slug'        => TagsPolicy::PERMISSION_DELETE,
168
            ],
169
        ];
170
    }
171
}
172