2025_09_04_073524_create_news_table.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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->foreignId('news_category_id')->references('id')->on('news_categories')->comment('文章類別');
  16. $table->string('news_img')->nullable()->comment('列表圖');
  17. $table->json('title')->comment("標題");
  18. $table->json('description')->nullable()->comment("短文");
  19. $table->json('written_by')->comment("編輯人");
  20. $table->dateTime('post_date')->comment("文章發布日");
  21. $table->string('meta_img')->nullable()->comment('seo image');
  22. $table->json("meta_title")->nullable()->comment("seo title");
  23. $table->json("meta_keyword")->nullable()->comment("seo keyword");
  24. $table->json("meta_description")->nullable()->comment("seo description");
  25. $table->boolean('on_top')->default(0)->comment("置頂");
  26. $table->boolean('visible')->default(1)->comment("顯示/隱藏");
  27. $table->unsignedInteger('order')->default(0)->comment("排序");
  28. $table->timestamps();
  29. $table->softDeletes();
  30. });
  31. Schema::enableForeignKeyConstraints();
  32. }
  33. /**
  34. * Reverse the migrations.
  35. */
  36. public function down(): void
  37. {
  38. Schema::dropIfExists('news');
  39. }
  40. };