AttributeTable::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 21
nc 1
nop 0
dl 0
loc 26
rs 9.584
c 1
b 0
f 0
1
<?php
2
3
use Illuminate\Database\Schema\Blueprint;
4
use Illuminate\Database\Migrations\Migration;
5
6
class AttributeTable extends Migration
7
{
8
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('attribute_group', function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->string('title');
19
            $table->enum('type', array('selectbox'))->default('selectbox');
20
            $table->enum('filter_type', array('selectbox', 'checkbox'))->nullable();
21
            $table->boolean('filter')->default(false);            
22
            $table->integer('shop_id')->unsigned();
23
            $table->foreign('shop_id')->references('id')->on('shop')->onDelete('cascade');
24
            $table->integer('modified_by_user_id')->unsigned()->nullable();
25
            $table->foreign('modified_by_user_id')->references('id')->on('user')->onDelete('set null');
26
            $table->timestamps();
27
            $table->unique(array('title','shop_id'), 'unique_attribute_group_title');
28
        });
29
30
31
        Schema::create('attribute', function (Blueprint $table) {
32
            $table->increments('id');
33
            $table->string('value');
34
            $table->integer('attribute_group_id')->unsigned();
35
            $table->foreign('attribute_group_id')->references('id')->on('attribute_group')->onDelete('cascade');
36
            $table->integer('modified_by_user_id')->unsigned()->nullable();
37
            $table->foreign('modified_by_user_id')->references('id')->on('user')->onDelete('set null');
38
            $table->timestamps();
39
            $table->unique(array('attribute_group_id','value'), 'unique_attribute_value');
40
        });
41
    }
42
43
    /**
44
     * Reverse the migrations.
45
     *
46
     * @return void
47
     */
48
    public function down()
49
    {
50
     //
51
    }
52
}
53