AclSeeder::insertRoles()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
use Illuminate\Database\Seeder;
4
5
class AclSeeder extends Seeder {
6
7
    public function run()
8
    {
9
        $this->insertPermissions();
10
        $this->insertRoles();
11
        $this->linkRolesAndPermissions();
12
    }
13
14 View Code Duplication
    private function insertPermissions()
15
    {
16
        // Truncate the table each time.
17
        DB::statement('SET FOREIGN_KEY_CHECKS=0;');
18
        DB::table('acl_permissions')->truncate();
19
        DB::statement('SET FOREIGN_KEY_CHECKS=1;');
20
21
        $permissions = config('users.permissions');
22
23
        // Add any data to the table.
24
        DB::table('acl_permissions')->insert($permissions);
25
    }
26
27 View Code Duplication
    private function insertRoles()
28
    {
29
        // Truncate the table each time.
30
        DB::statement('SET FOREIGN_KEY_CHECKS=0;');
31
        DB::table('acl_roles')->truncate();
32
        DB::statement('SET FOREIGN_KEY_CHECKS=1;');
33
34
        $roles = config('users.roles');
35
36
        // Add any data to the table.
37
        DB::table('acl_roles')->insert($roles);
38
    }
39
40 View Code Duplication
    private function linkRolesAndPermissions()
41
    {
42
        // Truncate the table each time.
43
        DB::statement('SET FOREIGN_KEY_CHECKS=0;');
44
        DB::table('acl_permission_role')->truncate();
45
        DB::statement('SET FOREIGN_KEY_CHECKS=1;');
46
47
        $permissions = config('users.permission_role');
48
49
        // Add any data to the table.
50
        DB::table('acl_permission_role')->insert($permissions);
51
    }
52
}
53