Completed
Pull Request — master (#4037)
by Muhlis
02:52
created

CreateTestTables::up()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 69

Duplication

Lines 9
Ratio 13.04 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 9
loc 69
rs 8.6763
c 0
b 0
f 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 Illuminate\Database\Schema\Blueprint;
5
6
class CreateTestTables extends Migration
7
{
8
    /**
9
     * Run the migrations.
10
     *
11
     * @return void
12
     */
13
    public function up()
14
    {
15
        Schema::create('test_images', function (Blueprint $table) {
16
            $table->increments('id');
17
            $table->string('image1');
18
            $table->string('image2');
19
            $table->string('image3');
20
            $table->string('image4');
21
            $table->string('image5');
22
            $table->string('image6');
23
            $table->timestamps();
24
        });
25
26
        Schema::create('test_multiple_images', function (Blueprint $table) {
27
            $table->increments('id');
28
            $table->text('pictures');
29
            $table->timestamps();
30
        });
31
32
        Schema::create('test_files', function (Blueprint $table) {
33
            $table->increments('id');
34
            $table->string('file1');
35
            $table->string('file2');
36
            $table->string('file3');
37
            $table->string('file4');
38
            $table->string('file5');
39
            $table->string('file6');
40
            $table->timestamps();
41
        });
42
43 View Code Duplication
        Schema::create('test_users', 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...
44
            $table->increments('id');
45
            $table->string('username');
46
            $table->string('email');
47
            $table->string('mobile')->nullable();
48
            $table->string('avatar')->nullable();
49
            $table->string('password');
50
            $table->timestamps();
51
        });
52
53
        Schema::create('test_user_profiles', function (Blueprint $table) {
54
            $table->increments('id');
55
            $table->string('user_id');
56
            $table->string('first_name')->nullable();
57
            $table->string('last_name')->nullable();
58
            $table->string('postcode')->nullable();
59
            $table->string('address')->nullable();
60
            $table->string('latitude')->nullable();
61
            $table->string('longitude')->nullable();
62
            $table->string('color')->nullable();
63
            $table->timestamp('start_at')->nullable();
64
            $table->timestamp('end_at')->nullable();
65
66
            $table->timestamps();
67
        });
68
69
        Schema::create('test_tags', function (Blueprint $table) {
70
            $table->increments('id');
71
            $table->string('name');
72
            $table->timestamps();
73
        });
74
75
        Schema::create('test_user_tags', function (Blueprint $table) {
76
            $table->integer('user_id');
77
            $table->integer('tag_id');
78
            $table->index(['user_id', 'tag_id']);
79
            $table->timestamps();
80
        });
81
    }
82
83
    /**
84
     * Reverse the migrations.
85
     *
86
     * @return void
87
     */
88
    public function down()
89
    {
90
        Schema::dropIfExists('test_images');
91
        Schema::dropIfExists('test_multiple_images');
92
        Schema::dropIfExists('test_files');
93
        Schema::dropIfExists('test_users');
94
        Schema::dropIfExists('test_user_profiles');
95
        Schema::dropIfExists('test_tags');
96
        Schema::dropIfExists('test_user_tags');
97
    }
98
}
99