Completed
Push — master ( f9e78a...edb43e )
by Abdelrahman
09:22
created

RolesSeeder::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 0
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Fort Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Fort Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
namespace Rinvex\Fort\Seeds;
17
18
use Rinvex\Fort\Models\Role;
19
use Illuminate\Database\Seeder;
20
use Illuminate\Support\Facades\DB;
21
22
class RolesSeeder extends Seeder
23
{
24
    /**
25
     * Run the database seeds.
26
     *
27
     * @return void
28
     */
29
    public function run()
30
    {
31
        DB::statement('SET FOREIGN_KEY_CHECKS=0;');
32
        DB::table(config('rinvex.fort.tables.roles'))->truncate();
33
34
        // Get roles data
35
        $roles = json_decode(file_get_contents(__DIR__.'/../../resources/data/roles.json'), true);
36
37
        // Create new roles
38
        foreach ($roles as $role) {
39
            Role::create($role);
40
        }
41
42
        // Grant abilities to roles
43
        Role::where('slug', 'admin')->first()->grantAbilities('superadmin', 'global');
44
45
        DB::statement('SET FOREIGN_KEY_CHECKS=1;');
46
    }
47
}
48