Completed
Push — master ( 0dfd17...a38508 )
by Sherif
02:04
created

AssignRelationsSeeder::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
dl 18
loc 18
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Modules\Roles\Database\Seeds;
4
5
use Illuminate\Database\Seeder;
6
7 View Code Duplication
class AssignRelationsSeeder extends Seeder
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /**
10
     * Run the database seeds.
11
     *
12
     * @return void
13
     */
14
    public function run()
15
    {
16
        $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id;
17
18
        /**
19
         * Assign the permissions to the admin group.
20
         */
21
        \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['role'])->each(function ($permission) use ($adminGroupId) {
22
            \DB::table('groups_permissions')->insert(
23
                [
24
                'permission_id' => $permission->id,
25
                'group_id'      => $adminGroupId,
26
                'created_at'    => \DB::raw('NOW()'),
27
                'updated_at'    => \DB::raw('NOW()')
28
                ]
29
            );
30
        });
31
    }
32
}
33