商品属性中间件表
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateGoodsAttributesTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('goods_attributes', function (Blueprint $table) { $table->increments('id')->comment('商品属性主键id'); $table->string('name')->comment('商品属性名'); $table->integer('category_id')->comment('商品属性id'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('goods_attributes'); } }
属性表
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateGoodsAttributeValuesTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('goods_attribute_values', function (Blueprint $table) { $table->increments('id')->comment('商品属性值:主键id'); $table->string('name')->comment('商品属性值:名称'); $table->integer('attribute_id')->comment('商品属性值:名称'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('goods_attribute_values'); } }
库存表
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateGoodsSkusTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('goods_skus', function (Blueprint $table) { $table->increments('id')->comment('sku主键id'); $table->integer('goods_id')->comment('商品id'); $table->integer('attribute_id')->comment('属性id'); $table->integer('attribute_value_id')->comment('属性值id'); $table->integer('prcture_id')->comment('图片id'); $table->decimal('price', 8, 2)->default(0)->comment('价格'); $table->integer('stock')->default(0)->comment('库存'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('goods_skus'); } }
laravle的创建数据库的代码

