2025_05_20_043733_create_news_table.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. */
  10. public function up(): void
  11. {
  12. Schema::disableForeignKeyConstraints();
  13. Schema::create('news', function (Blueprint $table) {
  14. $table->id();
  15. $table->unsignedBigInteger('news_category_id')->index();
  16. $table->foreign('news_category_id')->references('id')->on('news_categories')->comment('文章類別');
  17. $table->string('news_img_pc')->nullable()->comment('列表圖 PC');
  18. $table->string('news_img_mobile')->nullable()->comment('列表圖 MOBILE');
  19. $table->json('title')->comment("標題");
  20. $table->json('description')->comment("短文");
  21. $table->json('written_by')->comment("編輯人");
  22. $table->dateTime('post_date')->comment("文章發布日");
  23. $table->string('meta_img')->nullable()->comment('seo image');
  24. $table->json("meta_title")->nullable()->comment("seo title");
  25. $table->json("meta_keyword")->nullable()->comment("seo keyword");
  26. $table->json("meta_description")->nullable()->comment("seo description");
  27. $table->boolean('on_top')->default(0)->comment("置頂");
  28. $table->boolean('visible')->default(1)->comment("顯示/隱藏");
  29. $table->unsignedInteger('order')->default(0)->comment("排序");
  30. $table->timestamps();
  31. $table->softDeletes();
  32. });
  33. Schema::enableForeignKeyConstraints();
  34. }
  35. /**
  36. * Reverse the migrations.
  37. */
  38. public function down(): void
  39. {
  40. Schema::dropIfExists('news');
  41. }
  42. };