From 4dd9f58bbbd0d94f5a0f041713942d9d83c2fa55 Mon Sep 17 00:00:00 2001 From: Summer Date: Thu, 19 Sep 2019 11:21:13 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=B1=BB=E6=A8=A1=E5=9E=8B=E5=92=8C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Category.php | 12 ++++++ ...9_09_19_191731_create_categories_table.php | 23 ++++++++++++ ...2019_09_19_192022_seed_categories_data.php | 37 +++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 app/Models/Category.php create mode 100644 database/migrations/2019_09_19_191731_create_categories_table.php create mode 100644 database/migrations/2019_09_19_192022_seed_categories_data.php 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(); + } +}