GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( fa2630...81edb2 )
by Alireza
08:56
created

CreateRolesTables::up()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 86
Code Lines 53

Duplication

Lines 32
Ratio 37.21 %
Metric Value
dl 32
loc 86
rs 8.6583
cc 1
eloc 53
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
use Illuminate\Database\Schema\Blueprint;
4
use Illuminate\Database\Migrations\Migration;
5
6
class CreateRolesTables extends Migration
7
{
8
    /**
9
     * Run the migrations.
10
     *
11
     * @return void
12
     */
13
    public function up()
14
    {
15
      Schema::create('roles', function (Blueprint $table) {
16
        $table->increments('id');
17
        $table->string('name');
18
        $table->string('label')->nullable();
19
        $table->timestamps();
20
      });
21
22
      Schema::create('permissions', function (Blueprint $table) {
23
        $table->increments('id');
24
        $table->string('name');
25
        $table->string('label')->nullable();
26
        $table->timestamps();
27
      });
28
29 View Code Duplication
      Schema::create('permission_role', function (Blueprint $table) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
30
        $table->integer('permission_id')->unsigned();
31
        $table->integer('role_id')->unsigned();
32
33
        $table->foreign('permission_id')
34
        ->references('id')
35
        ->on('permissions')
36
        ->onDelete('cascade');
37
38
        $table->foreign('role_id')
39
        ->references('id')
40
        ->on('roles')
41
        ->onDelete('cascade');
42
43
        $table->primary(['permission_Id', 'role_id']);
44
      });
45
46 View Code Duplication
      Schema::create('admin_role', function (Blueprint $table) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
47
        $table->integer('role_id')->unsigned();
48
        $table->integer('admin_id')->unsigned();
49
50
        $table->foreign('role_id')
51
        ->references('id')
52
        ->on('roles')
53
        ->onDelete('cascade');
54
55
        $table->foreign('admin_id')
56
        ->references('id')
57
        ->on('admins')
58
        ->onDelete('cascade');
59
60
        $table->primary(['role_id', 'admin_id']);
61
      });
62
    	//seed database for admin and initiate super role
63
      DB::table('roles')->insert([
64
        'name' => 'super',
65
        'label' => 'This goup has all permissions' ,
66
67
        ]);
68
69
      DB::table('admin_role')->insert([
70
        'role_id' => '1',
71
        'admin_id' => '1' ,
72
73
        ]);
74
75
// show Roles on panel
76
      DB::table('links')->insert(
77
        array('display' => 'Roles',
78
          'url' => 'Role', 
79
          'main' => '1'
80
          ));
81
82
// show Permission on panel
83
      DB::table('links')->insert(
84
        array('display' => 'Permissions',
85
          'url' => 'Permission', 
86
          'main' => '1'
87
          ));
88
89
          // show Admin on panel
90
      DB::table('links')->insert(
91
        array('display' => 'Admins',
92
          'url' => 'Admin', 
93
          'main' => '1'
94
          ));
95
96
97
98
    }
99
100
    /**
101
     * Reverse the migrations.
102
     *
103
     * @return void
104
     */
105
    public function down()
106
    {
107
        //
108
    }
109
  }
110