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.
Passed
Push — master ( 11f3a5...9dc363 )
by Tharindu
04:00
created

CreatePermissionTables::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 59
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 40
nc 1
nop 0
dl 0
loc 59
rs 9.597
c 1
b 0
f 1

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\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreatePermissionTables extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     */
12
    public function up()
13
    {
14
        $tableNames = config('permission.table_names');
15
16
        Schema::create($tableNames['permissions'], function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->string('name');
19
            $table->string('guard_name');
20
            $table->timestamps();
21
        });
22
23
        Schema::create($tableNames['roles'], function (Blueprint $table) {
24
            $table->increments('id');
25
            $table->string('name');
26
            $table->string('guard_name');
27
            $table->timestamps();
28
        });
29
30
        Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames) {
31
            $table->unsignedInteger('permission_id');
32
            $table->morphs('model');
33
34
            $table->foreign('permission_id')
35
                ->references('id')
36
                ->on($tableNames['permissions'])
37
                ->onDelete('cascade');
38
39
            $table->primary(['permission_id', 'model_id', 'model_type']);
40
        });
41
42
        Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames) {
43
            $table->unsignedInteger('role_id');
44
            $table->morphs('model');
45
46
            $table->foreign('role_id')
47
                ->references('id')
48
                ->on($tableNames['roles'])
49
                ->onDelete('cascade');
50
51
            $table->primary(['role_id', 'model_id', 'model_type']);
52
        });
53
54
        Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
55
            $table->unsignedInteger('permission_id');
56
            $table->unsignedInteger('role_id');
57
58
            $table->foreign('permission_id')
59
                ->references('id')
60
                ->on($tableNames['permissions'])
61
                ->onDelete('cascade');
62
63
            $table->foreign('role_id')
64
                ->references('id')
65
                ->on($tableNames['roles'])
66
                ->onDelete('cascade');
67
68
            $table->primary(['permission_id', 'role_id']);
69
70
            app('cache')->forget('spatie.permission.cache');
71
        });
72
    }
73
74
    /**
75
     * Reverse the migrations.
76
     */
77
    public function down()
78
    {
79
        $tableNames = config('permission.table_names');
80
81
        Schema::drop($tableNames['role_has_permissions']);
82
        Schema::drop($tableNames['model_has_roles']);
83
        Schema::drop($tableNames['model_has_permissions']);
84
        Schema::drop($tableNames['roles']);
85
        Schema::drop($tableNames['permissions']);
86
    }
87
}
88