Completed
Push — 2.0 ( d74017...53a0fa )
by Nicolas
15:37
created

SentinelGroupSeedTableSeeder::run()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 80
Code Lines 55

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 80
rs 8.8387
cc 1
eloc 55
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php namespace Modules\User\Database\Seeders;
2
3
use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
4
use Illuminate\Database\Eloquent\Model;
5
use Illuminate\Database\Seeder;
6
7
class SentinelGroupSeedTableSeeder extends Seeder
8
{
9
    /**
10
     * Run the database seeds.
11
     *
12
     * @return void
13
     */
14
    public function run()
15
    {
16
        Model::unguard();
17
18
        $groups = Sentinel::getRoleRepository();
19
20
        // Create an Admin group
21
        $groups->createModel()->create(
22
            [
23
                'name' => 'Admin',
24
                'slug' => 'admin',
25
            ]
26
        );
27
28
        // Create an Users group
29
        $groups->createModel()->create(
30
            [
31
                'name' => 'User',
32
                'slug' => 'user',
33
            ]
34
        );
35
36
        // Save the permissions
37
        $group = Sentinel::findRoleBySlug('admin');
38
        $group->permissions = [
39
            'dashboard.index' => true,
40
            'dashboard.update' => true,
41
            'dashboard.reset' => true,
42
            /* Workbench */
43
            'workshop.modules.index' => true,
44
            'workshop.modules.show' => true,
45
            'workshop.modules.disable' => true,
46
            'workshop.modules.enable' => true,
47
            'workshop.modules.update' => true,
48
            'workshop.themes.index' => true,
49
            'workshop.themes.show' => true,
50
            /* Roles */
51
            'user.roles.index' => true,
52
            'user.roles.create' => true,
53
            'user.roles.edit' => true,
54
            'user.roles.destroy' => true,
55
            /* Users */
56
            'user.users.index' => true,
57
            'user.users.create' => true,
58
            'user.users.edit' => true,
59
            'user.users.destroy' => true,
60
            /* API keys */
61
            'account.api-keys.index' => true,
62
            'account.api-keys.create' => true,
63
            'account.api-keys.destroy' => true,
64
            /* Menu */
65
            'menu.menus.index' => true,
66
            'menu.menus.create' => true,
67
            'menu.menus.edit' => true,
68
            'menu.menus.destroy' => true,
69
            'menu.menuitems.index' => true,
70
            'menu.menuitems.create' => true,
71
            'menu.menuitems.edit' => true,
72
            'menu.menuitems.destroy' => true,
73
            /* Media */
74
            'media.medias.index' => true,
75
            'media.medias.create' => true,
76
            'media.medias.edit' => true,
77
            'media.medias.destroy' => true,
78
            /* Settings */
79
            'setting.settings.index' => true,
80
            'setting.settings.edit' => true,
81
            /* Page */
82
            'page.pages.index' => true,
83
            'page.pages.create' => true,
84
            'page.pages.edit' => true,
85
            'page.pages.destroy' => true,
86
            /* Translation */
87
            'translation.translations.index' => true,
88
            'translation.translations.edit' => true,
89
            'translation.translations.export' => true,
90
            'translation.translations.import' => true,
91
        ];
92
        $group->save();
93
    }
94
}
95