Completed
Push — master ( b11988...18b0fe )
by wen
10:56
created

RbacTableSeeder::insertRoles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 14
nc 1
nop 0
1
<?php
2
3
use Illuminate\Database\Seeder;
4
use Carbon\Carbon;
5
6
class RbacTableSeeder extends Seeder
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
    private $managerModel;
9
10 View Code Duplication
    public function __construct()
0 ignored issues
show
Duplication introduced by
This method 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...
11
    {
12
        $guard              = config('admin.guard');
13
        $provider           = config("auth.guards.{$guard}.provider");
14
        $managerModelName   = config("auth.providers.{$provider}.model");
15
        $this->managerModel = new $managerModelName();
16
    }
17
18
    /**
19
     * Run the database seeds.
20
     *
21
     * @return void
22
     */
23
    public function run()
24
    {
25
        $this->insertManager();
26
        //$this->insertRoleUser();
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
27
28
29
        $database = file_get_contents(__DIR__ . '/' . 'rbac.sql');
30
        $prefix   = env('DB_PREFIX', '');
31
        $database = str_replace('sco_', $prefix, $database);
32
33
        DB::connection()->getPdo()->exec($database);
34
    }
35
36 View Code Duplication
    private function insertManager()
0 ignored issues
show
Duplication introduced by
This method 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...
37
    {
38
        $managerTable = $this->managerModel->getTable();
39
        if ($managerTable != 'users') {
40
            DB::table($managerTable)->insert([
41
                'id'         => 1,
42
                'name'       => 'admin',
43
                'email'      => '[email protected]',
44
                'password'   => bcrypt('123456'),
45
                'created_at' => Carbon::now(),
46
                'updated_at' => Carbon::now(),
47
            ]);
48
        }
49
    }
50
51
    private function insertRoleUser()
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
52
    {
53
        DB::table('role_user')->insert([
54
            'manager_id' => 1,
55
            'role_id'    => 1,
56
        ]);
57
    }
58
}
59