| Total Complexity | 2 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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() |
||
| 50 | // |
||
| 51 | } |
||
| 53 |