DefaultConnectRelationshipsSeeder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 19 2
1
<?php
2
3
namespace jeremykenedy\LaravelRoles\Database\Seeders;
4
5
use Illuminate\Database\Seeder;
6
7
class DefaultConnectRelationshipsSeeder extends Seeder
8
{
9
    /**
10
     * Run the database seeds.
11
     *
12
     * @return void
13
     */
14
    public function run()
15
    {
16
        /**
17
         * Get Available Permissions.
18
         */
19
        $permissions = config('roles.models.permission')::all();
20
21
        /**
22
         * Attach Permissions to Roles.
23
         */
24
        $roleAdmin = config('roles.models.role')::where('slug', '=', 'admin')->first()
25
            ?? config('roles.models.role')::where('name', '=', 'Admin')->first();
26
27
        $this->command->getOutput()->writeln('<info>Seeding:</info> DefaultConnectRelationshipsSeeder');
28
        foreach ($permissions as $permission) {
29
            $roleAdmin->attachPermission($permission);
30
            $this->command->getOutput()->writeln(
31
                '<info>Seeding:</info> DefaultConnectRelationshipsSeeder - Role:Admin attached to Permission:'
32
                .$permission->slug
33
            );
34
        }
35
    }
36
}
37