CreateBaseTables::up()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 123
Code Lines 90

Duplication

Lines 32
Ratio 26.02 %

Importance

Changes 5
Bugs 0 Features 2
Metric Value
c 5
b 0
f 2
dl 32
loc 123
rs 8.2857
cc 1
eloc 90
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\Migrations\Migration;
4
use \jlourenco\support\Database\Blueprint;
5
6
class CreateBaseTables extends Migration
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
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
17
        Schema::create('User', function (Blueprint $table) {
18
            $table->increments('id');
19
            $table->string('username', 25)->nullable()->unique();
20
            $table->string('password', 60)->nullable();
21
            $table->string('first_name', 25);
22
            $table->string('last_name', 25);
23
            $table->string('email')->unique();
24
            $table->text('description')->nullable();
25
            $table->timestamp('birthday')->nullable();
26
            $table->string('pic')->nullable();
27
            $table->integer('gender');
28
            $table->tinyInteger('status');
29
            $table->string('ip', 15);
30
            $table->tinyInteger('staff');
31
            $table->tinyInteger('force_new_password');
32
            $table->timestamp('last_login')->nullable();
33
            $table->text('permissions')->nullable();
34
            $table->rememberToken();
35
            $table->timestamps();
36
            $table->softDeletes();
37
            $table->creation();
38
        });
39
40
        Schema::table('User', function (Blueprint $table) {
41
            $table->creationRelation();
42
        });
43
44
        Schema::create('Visits', function (Blueprint $table) {
45
            $table->increments('id');
46
            $table->string('url')->nullable();
47
            $table->string('ip', 15)->nullable();
48
            $table->string('browser')->nullable();
49
            $table->tinyInteger('checked');
50
51
            $table->string('isoCode')->nullable();
52
            $table->string('country')->nullable();
53
            $table->string('city')->nullable();
54
            $table->string('state')->nullable();
55
            $table->string('postal_code')->nullable();
56
            $table->string('lat')->nullable();
57
            $table->string('lon')->nullable();
58
            $table->string('timezone')->nullable();
59
            $table->string('continent')->nullable();
60
            $table->timestamps();
61
        });
62
63
        Schema::create('Logs', function (Blueprint $table) {
64
            $table->increments('id');
65
            $table->text('log');
66
            $table->integer('target')->nullable();
67
            $table->string('ip', 15)->nullable();
68
            $table->timestamps();
69
            $table->creation();
70
        });
71
72
        Schema::table('Logs', function (Blueprint $table) {
73
            $table->creationRelation();
74
        });
75
76 View Code Duplication
        Schema::create('Settings', 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...
77
            $table->increments('id');
78
            $table->string('friendly_name', 25);
79
            $table->string('name', 25);
80
            $table->string('value', 150)->nullable();
81
            $table->string('description', 250)->nullable();
82
            $table->timestamps();
83
            $table->creation();
84
        });
85
86
        Schema::table('Settings', function (Blueprint $table) {
87
            $table->creationRelation();
88
        });
89
90 View Code Duplication
        Schema::create('Group', 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...
91
            $table->increments('id');
92
            $table->string('name', 25);
93
            $table->string('description', 250)->nullable();
94
            $table->string('slug', 250);
95
            $table->text('permissions')->nullable();
96
97
            $table->timestamps();
98
            $table->softDeletes();
99
            $table->creation();
100
101
            $table->unique('slug');
102
        });
103
104
        Schema::table('Group', function (Blueprint $table) {
105
            $table->creationRelation();
106
        });
107
108
        Schema::create('Group_User', function (Blueprint $table) {
109
            $table->increments('id');
110
            $table->integer('user')->unsigned();
111
            $table->integer('group')->unsigned();
112
113
            $table->timestamps();
114
            $table->softDeletes();
115
            $table->creation();
116
117
            $table->foreign('user')->references('id')->on('User');
118
            $table->foreign('group')->references('id')->on('Group');
119
        });
120
121
        Schema::table('Group_User', function (Blueprint $table) {
122
            $table->creationRelation();
123
        });
124
125 View Code Duplication
        Schema::create('ActivityFeed', 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...
126
            $table->increments('id');
127
            $table->string('added_by', 150);
128
            $table->text('activity');
129
            $table->string('icon', 100);
130
            $table->string('link', 250)->nullable();
131
            $table->text('permissions')->nullable();
132
133
            $table->timestamps();
134
        });
135
136
    }
137
138
    /**
139
     * Reverse the migrations.
140
     *
141
     * @return void
142
     */
143
    public function down()
144
    {
145
146
        Schema::drop('Logs');
147
        Schema::drop('Visits');
148
        Schema::drop('Settings');
149
        Schema::drop('Group_User');
150
        Schema::drop('Group');
151
        Schema::drop('ActivityFeed');
152
        Schema::drop('User');
153
154
    }
155
156
}
157