Completed
Push — master ( 9e3353...dc977e )
by Joao
02:24
created

CreateBaseTables   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 112
Duplicated Lines 19.64 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 2
lcom 1
cbo 1
dl 22
loc 112
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B up() 22 84 1
A down() 0 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use \jlourenco\base\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->tinyInteger('status');
27
            $table->string('ip', 15);
28
            $table->binary('staff');
29
            $table->timestamp('last_login')->nullable();
30
            $table->text('permissions')->nullable();
31
            $table->rememberToken();
32
            $table->timestamps();
33
            $table->softDeletes();
34
            $table->creation();
35
        });
36
37
        Schema::create('Logs', function (Blueprint $table) {
38
            $table->increments('id');
39
            $table->text('log');
40
            $table->timestamps();
41
            $table->creation();
42
        });
43
44
        Schema::create('Settings', function (Blueprint $table) {
45
            $table->increments('id');
46
            $table->string('friendy_name', 25);
47
            $table->string('name', 25);
48
            $table->string('vale', 150)->nullable();
49
            $table->string('description', 250)->nullable();
50
            $table->creation();
51
        });
52
53 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...
54
            $table->increments('id');
55
            $table->string('name', 25);
56
            $table->string('description', 250)->nullable();
57
            $table->string('slug', 250);
58
            $table->text('permissions')->nullable();
59
60
            $table->timestamps();
61
            $table->softDeletes();
62
            $table->creation();
63
            $table->unique('slug');
64
        });
65
66
        Schema::create('Group_User', function (Blueprint $table) {
67
            $table->increments('id');
68
            $table->integer('user')->unsigned();
69
            $table->integer('group')->unsigned();
70
71
            $table->nullableTimestamps();
72
            $table->creation();
73
74
            $table->foreign('user')->references('id')->on('User');
75
            $table->foreign('group')->references('id')->on('Group');
76
        });
77
78 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...
79
            $table->increments('id');
80
            $table->string('added_by', 150);
81
            $table->text('activity');
82
            $table->string('icon', 100);
83
            $table->timestamp('visibility');
84
            $table->string('link', 250)->nullable();
85
            $table->text('requirements')->nullable();
86
            $table->timestamps();
87
        });
88
89
        Schema::create('Permission', function (Blueprint $table) {
90
            $table->increments('id');
91
            $table->string('key', 100);
92
            $table->string('description', 250);
93
94
            $table->unique('key');
95
        });
96
97
    }
98
99
    /**
100
     * Reverse the migrations.
101
     *
102
     * @return void
103
     */
104
    public function down()
105
    {
106
107
        Schema::drop('Logs');
108
        Schema::drop('Settings');
109
        Schema::drop('Group_User');
110
        Schema::drop('Group');
111
        Schema::drop('ActivityFeed');
112
        Schema::drop('Permission');
113
        Schema::drop('User');
114
115
    }
116
117
}
118