CreateContents   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 100
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldTableFields() 0 11 1
B up() 0 64 1
A down() 0 10 1
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
6
class CreateContents extends Migration
7
{
8
    public function fieldTableFields(Blueprint $table)
9
    {
10
        $table->increments('id');
11
        $table->string('name');
12
        $table->integer('weight');
13
14
        $table->timestamps();
15
16
        $table->unsignedInteger('revision_id');
17
        $table->foreign('revision_id')->references('id')->on('revisions');
18
    }
19
20
    /**
21
     * Run the migrations.
22
     *
23
     * @return void
24
     */
25
    public function up()
26
    {
27
        Schema::create(
28
            'contents',
29
            function (Blueprint $table) {
30
                $table->increments('id');
31
                $table->timestamps();
32
            }
33
        );
34
35
        Schema::create(
36
            'revisions',
37
            function (Blueprint $table) {
38
                $table->increments('id');
39
                $table->unsignedInteger('language_id');
40
                $table->unsignedInteger('content_id');
41
                $table->timestamps();
42
43
                $table->foreign('language_id')->references('id')->on('languages');
44
                $table->foreign('content_id')->references('id')->on('contents');
45
            }
46
        );
47
48
        Schema::create(
49
            'field_string',
50
            function (Blueprint $table) {
51
                $this->fieldTableFields($table);
52
                $table->string('value');
53
            }
54
        );
55
56
        Schema::create(
57
            'field_text',
58
            function (Blueprint $table) {
59
                $this->fieldTableFields($table);
60
                $table->text('value');
61
            }
62
        );
63
64
        Schema::create(
65
            'field_date',
66
            function (Blueprint $table) {
67
                $this->fieldTableFields($table);
68
                $table->date('value');
69
            }
70
        );
71
72
        Schema::create(
73
            'field_datetime',
74
            function (Blueprint $table) {
75
                $this->fieldTableFields($table);
76
                $table->datetime('value');
77
            }
78
        );
79
80
        Schema::create(
81
            'field_entity',
82
            function (Blueprint $table) {
83
                $this->fieldTableFields($table);
84
                $table->unsignedInteger('value');
85
                $table->foreign('value')->references('id')->on('contents');
86
            }
87
        );
88
    }
89
90
    /**
91
     * Reverse the migrations.
92
     *
93
     * @return void
94
     */
95
    public function down()
96
    {
97
        Schema::drop('field_string');
98
        Schema::drop('field_text');
99
        Schema::drop('field_date');
100
        Schema::drop('field_datetime');
101
        Schema::drop('field_entity');
102
        Schema::drop('revisions');
103
        Schema::drop('contents');
104
    }
105
}
106