id(); // 文章基本欄位 $table->string('title', 500)->comment('標題'); $table->string('slug', 500)->unique()->comment('URL slug (唯一)'); $table->longText('content')->nullable()->comment('完整內容 (HTML)'); $table->text('excerpt')->nullable()->comment('摘要'); $table->enum('status', ['draft', 'publish'])->default('draft')->comment('發布狀態'); $table->enum('post_type', ['news', 'event'])->comment('文章類型: news=新聞, event=活動'); $table->dateTime('published_at')->nullable()->comment('發布時間'); // ACF 自訂欄位 (新聞/活動共用) $table->date('date')->nullable()->comment('日期 (新聞/活動共用)'); $table->string('time', 50)->nullable()->comment('時間 (僅活動使用, 如: "0830-1630")'); $table->string('image_url', 500)->nullable()->comment('圖片相對路徑 (如: 2025/07/image.png)'); // ACF 自訂欄位 (僅活動使用) $table->string('address', 500)->nullable()->comment('活動地址 (僅活動)'); $table->text('description')->nullable()->comment('活動說明 HTML (僅活動)'); $table->string('link', 500)->nullable()->comment('活動連結 (僅活動)'); $table->boolean('featured_image')->default(false)->comment('是否有特色圖片'); $table->timestamps(); // 索引設計 (依照資料結構文件建議) $table->index('post_type', 'idx_post_type'); $table->index('status', 'idx_status'); $table->index('published_at', 'idx_published_at'); $table->index('slug', 'idx_slug'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('posts'); } };