AddBaseFields::fieldTableFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 11
ccs 8
cts 8
cp 1
crap 1
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
6
class AddBaseFields extends Migration
7
{
8 117
    public function fieldTableFields(Blueprint $table)
9
    {
10 117
        $table->increments('id');
11 117
        $table->string('name');
12 117
        $table->integer('weight');
13
14 117
        $table->timestamps();
15
16 117
        $table->unsignedInteger('revision_id');
17 117
        $table->foreign('revision_id')->references('id')->on('revisions');
18 117
    }
19
20
    /**
21
     * Run the migrations.
22
     *
23
     * @return void
24
     */
25 117
    public function up()
26
    {
27 117
        Schema::create(
28 117
            'field_integer',
29
            function (Blueprint $table) {
30 117
                $this->fieldTableFields($table);
31 117
                $table->integer('value');
32 117
            }
33 117
        );
34
35 117
        Schema::create(
36 117
            'field_double',
37
            function (Blueprint $table) {
38 117
                $this->fieldTableFields($table);
39 117
                $table->double('value');
40 117
            }
41 117
        );
42
43 117
        Schema::create(
44 117
            'field_boolean',
45 117
            function (Blueprint $table) {
46 117
                $this->fieldTableFields($table);
47 117
                $table->boolean('value');
48 117
            }
49 117
        );
50 117
    }
51
52
    /**
53
     * Reverse the migrations.
54
     *
55
     * @return void
56
     */
57 117
    public function down()
58
    {
59 117
        Schema::drop('field_integer');
60 117
        Schema::drop('field_double');
61 117
        Schema::drop('field_boolean');
62 117
    }
63
}
64