Test Setup Failed
Pull Request — master (#34)
by Jeremy
04:44
created

PermissionsTableSeeder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 45 3
1
<?php
2
3
namespace Database\Seeds;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Seeder;
7
8
class PermissionsTableSeeder extends Seeder
9
{
10
    /**
11
     * Run the database seeds.
12
     *
13
     * @return void
14
     */
15
    public function run()
16
    {
17
        /*
18
         * Permission Types
19
         *
20
         */
21
        $Permissionitems = [
22
            [
23
                'name'        => 'Can View Users',
24
                'slug'        => 'view.users',
25
                'description' => 'Can view users',
26
                'model'       => 'Permission',
27
            ],
28
            [
29
                'name'        => 'Can Create Users',
30
                'slug'        => 'create.users',
31
                'description' => 'Can create new users',
32
                'model'       => 'Permission',
33
            ],
34
            [
35
                'name'        => 'Can Edit Users',
36
                'slug'        => 'edit.users',
37
                'description' => 'Can edit users',
38
                'model'       => 'Permission',
39
            ],
40
            [
41
                'name'        => 'Can Delete Users',
42
                'slug'        => 'delete.users',
43
                'description' => 'Can delete users',
44
                'model'       => 'Permission',
45
            ],
46
        ];
47
48
        /*
49
         * Add Permission Items
50
         *
51
         */
52
        foreach ($Permissionitems as $Permissionitem) {
53
            $newPermissionitem = config('roles.models.permission')::where('slug', '=', $Permissionitem['slug'])->first();
54
            if ($newPermissionitem === null) {
55
                $newPermissionitem = config('roles.models.permission')::create([
0 ignored issues
show
Unused Code introduced by
The assignment to $newPermissionitem is dead and can be removed.
Loading history...
56
                    'name'          => $Permissionitem['name'],
57
                    'slug'          => $Permissionitem['slug'],
58
                    'description'   => $Permissionitem['description'],
59
                    'model'         => $Permissionitem['model'],
60
                ]);
61
            }
62
        }
63
    }
64
}
65