CreateContents   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 2 Features 0
Metric Value
c 6
b 2
f 0
dl 0
loc 100
ccs 67
cts 67
cp 1
rs 10
wmc 3
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldTableFields() 0 11 1
A 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 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
            'contents',
29
            function (Blueprint $table) {
30 117
                $table->increments('id');
31 117
                $table->timestamps();
32 117
            }
33 117
        );
34
35 117
        Schema::create(
36 117
            'revisions',
37
            function (Blueprint $table) {
38 117
                $table->increments('id');
39 117
                $table->unsignedInteger('language_id');
40 117
                $table->unsignedInteger('content_id');
41 117
                $table->timestamps();
42
43 117
                $table->foreign('language_id')->references('id')->on('languages');
44 117
                $table->foreign('content_id')->references('id')->on('contents');
45 117
            }
46 117
        );
47
48 117
        Schema::create(
49 117
            'field_string',
50
            function (Blueprint $table) {
51 117
                $this->fieldTableFields($table);
52 117
                $table->string('value');
53 117
            }
54 117
        );
55
56 117
        Schema::create(
57 117
            'field_text',
58
            function (Blueprint $table) {
59 117
                $this->fieldTableFields($table);
60 117
                $table->text('value');
61 117
            }
62 117
        );
63
64 117
        Schema::create(
65 117
            'field_date',
66
            function (Blueprint $table) {
67 117
                $this->fieldTableFields($table);
68 117
                $table->date('value');
69 117
            }
70 117
        );
71
72 117
        Schema::create(
73 117
            'field_datetime',
74
            function (Blueprint $table) {
75 117
                $this->fieldTableFields($table);
76 117
                $table->datetime('value');
77 117
            }
78 117
        );
79
80 117
        Schema::create(
81 117
            'field_entity',
82 117
            function (Blueprint $table) {
83 117
                $this->fieldTableFields($table);
84 117
                $table->unsignedInteger('value');
85 117
                $table->foreign('value')->references('id')->on('contents');
86 117
            }
87 117
        );
88 117
    }
89
90
    /**
91
     * Reverse the migrations.
92
     *
93
     * @return void
94
     */
95 117
    public function down()
96
    {
97 117
        Schema::drop('field_string');
98 117
        Schema::drop('field_text');
99 117
        Schema::drop('field_date');
100 117
        Schema::drop('field_datetime');
101 117
        Schema::drop('field_entity');
102 117
        Schema::drop('revisions');
103 117
        Schema::drop('contents');
104 117
    }
105
}
106