<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::disableForeignKeyConstraints();

        Schema::create('news', function (Blueprint $table) {
            $table->id();
            $table->foreignId('news_category_id')->references('id')->on('news_categories')->comment('文章類別');
            $table->string('news_img')->nullable()->comment('列表圖');
            $table->string('news_img_alt')->nullable()->comment('列表圖 ALT');
            $table->json('title')->comment("標題");
            $table->json('description')->nullable()->comment("短文");
            $table->json('written_by')->comment("編輯人");
            $table->dateTime('post_date')->comment("文章發布日");
            $table->string('meta_img')->nullable()->comment('seo image');
            $table->json("meta_title")->nullable()->comment("seo title");
            $table->json("meta_keyword")->nullable()->comment("seo keyword");
            $table->json("meta_description")->nullable()->comment("seo description");
            $table->boolean('on_top')->default(0)->comment("置頂");
            $table->boolean('visible')->default(1)->comment("顯示/隱藏");
            $table->unsignedInteger('order')->default(0)->comment("排序");
            $table->timestamps();
            $table->softDeletes();
        });

        Schema::enableForeignKeyConstraints();
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('news');
    }
};
