diff --git a/app/Models/Category.php b/app/Models/Category.php new file mode 100644 index 000000000..0954ad732 --- /dev/null +++ b/app/Models/Category.php @@ -0,0 +1,12 @@ +increments('id'); + $table->string('name')->index()->comment('名称'); + $table->text('description')->nullable()->comment('描述'); + $table->integer('post_count')->default(0)->comment('帖子数'); + }); + } + + public function down() + { + Schema::dropIfExists('categories'); + } +} diff --git a/database/migrations/2019_09_19_192022_seed_categories_data.php b/database/migrations/2019_09_19_192022_seed_categories_data.php new file mode 100644 index 000000000..020ab8dee --- /dev/null +++ b/database/migrations/2019_09_19_192022_seed_categories_data.php @@ -0,0 +1,37 @@ + '分享', + 'description' => '分享创造,分享发现', + ], + [ + 'name' => '教程', + 'description' => '开发技巧、推荐扩展包等', + ], + [ + 'name' => '问答', + 'description' => '请保持友善,互帮互助', + ], + [ + 'name' => '公告', + 'description' => '站点公告', + ], + ]; + + DB::table('categories')->insert($categories); + } + + public function down() + { + DB::table('categories')->truncate(); + } +}