コード例 #1
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('users', function (Blueprint $table) {
         $table->increments('id')->comment('用户ID');
         $table->string('mobile', 20)->index('mobile')->nullable()->comment('手机号');
         $table->string('email', 100)->index('email')->nullable()->comment('邮箱');
         $table->string('password', 64)->nullable()->comment('密码');
         $table->enum('status', Status::getValues())->default(Status::ENABLE)->comment('状态');
         // timestamp fields
         $table->timestamps();
     });
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('post_categories', function (Blueprint $table) {
         $table->smallIncrements('id')->comment('类别ID');
         $table->string('name', 20)->comment('名称');
         $table->unsignedSmallInteger('parent_id')->nullable()->comment('父类ID');
         $table->unsignedSmallInteger('count_sub_categories')->comment('子类个数');
         $table->enum('status', Status::getValues())->default(Status::ENABLE)->comment('状态');
         // timestamp fields
         $table->timestamps();
         // foreign key
         $table->foreign('parent_id')->references('id')->on('post_categories');
     });
     //
 }
コード例 #3
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('comments', function (Blueprint $table) {
         $table->increments('id')->comment('评论ID');
         $table->unsignedInteger('user_id')->comment('评论的用户ID');
         $table->unsignedInteger('post_id')->comment('所评论的信息ID');
         $table->unsignedInteger('parent_id')->nullable()->comment('父评论ID');
         $table->text('content')->comment('评论内容');
         $table->enum('status', Status::getValues())->default(Status::ENABLE)->comment('状态');
         // timestamp fields
         $table->timestamps();
         // foreign key
         $table->foreign('user_id')->references('id')->on('users');
         $table->foreign('post_id')->references('id')->on('posts');
         $table->foreign('parent_id')->references('id')->on('comments');
     });
     //
 }
コード例 #4
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('posts', function (Blueprint $table) {
         $table->increments('id')->comment('帖子id');
         $table->unsignedSmallInteger('post_category_id')->index('post_category_id')->comment('分类ID');
         $table->unsignedInteger('user_id')->comment('信息发布者用户 ID');
         $table->text('content')->nullable()->comment('信息内容');
         $table->unsignedInteger('count_images')->default(0)->comment('包含图片数量');
         $table->unsignedInteger('count_views')->default(0)->comment('阅读次数');
         $table->unsignedInteger('count_comments')->default(0)->comment('评论次数');
         // 小数点后6位 精确到4米
         $table->decimal('lng', 20, 6)->default(0.0)->index('lng')->comment('经度');
         $table->decimal('lat', 20, 6)->default(0.0)->index('lat')->comment('维度');
         $table->enum('status', Status::getValues())->default(Status::ENABLE)->comment('状态');
         $table->boolean('deleted')->default(false)->comment('删除状态');
         // timestamp fields
         $table->timestamps();
         // foreign key
         $table->foreign('user_id')->references('id')->on('users');
         $table->foreign('post_category_id')->references('id')->on('post_categories');
     });
     //
 }