Completed
Push — master ( fa7b60...6c1318 )
by Mahmoud
03:02
created

RolesAndPermissionsSeeder::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 64
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 64
rs 9.3956
cc 1
eloc 30
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
2
3
namespace App\Containers\Authorization\Data\Seeders;
4
5
use App\Containers\Authorization\Models\Permission;
6
use App\Containers\Authorization\Models\Role;
7
use App\Port\Seeder\Abstracts\Seeder;
8
9
class RolesAndPermissionsSeeder extends Seeder
10
{
11
12
    /**
13
     * Run the database seeds.
14
     *
15
     * @return void
16
     */
17
    public function run()
18
    {
19
        // Default Roles ----------------------------------------------------------------
20
        // ------------------------------------------------------------------------------
21
22
        $roleAdmin = Role::create([
23
            'name'         => 'admin',
24
            'description'  => 'Super Administrator',
25
            'display_name' => '',
26
        ]);
27
28
        $roleClient = Role::create([
29
            'name'         => 'client',
30
            'description'  => 'Normal User',
31
            'display_name' => '',
32
        ]);
33
34
        // Default Permissions ----------------------------------------------------------
35
        // ------------------------------------------------------------------------------
36
37
        $p = Permission::create([
38
            'name'         => 'list-all-users',
39
            'description'  => 'List all users in the system',
40
            'display_name' => '',
41
        ]);
42
43
        $roleAdmin->givePermissionTo($p);
44
45
        // ---------------------------------------
46
47
        $p = Permission::create([
48
            'name'         => 'delete-user',
49
            'description'  => '',
50
            'display_name' => '',
51
        ]);
52
53
        $roleAdmin->givePermissionTo($p);
54
55
        // ---------------------------------------
56
57
        $p = Permission::create([
58
            'name'         => 'update-user',
59
            'description'  => '',
60
            'display_name' => '',
61
        ]);
62
63
        $roleClient->givePermissionTo($p);
64
        $roleAdmin->givePermissionTo($p);
65
66
        // ---------------------------------------
67
68
        $p = Permission::create([
69
            'name'         => 'manage-roles-permissions',
70
            'description'  => 'Create, View, Modify, Assign, Attach.. Roles and Permissions for Users',
71
            'display_name' => '',
72
        ]);
73
74
        $roleAdmin->givePermissionTo($p);
75
76
        // ---------------------------------------
77
78
        // ...
79
80
    }
81
}
82