<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('class_courses', function (Blueprint $table) {
            $table->id()->comment('主鍵');

            // slug：用於網址/路由（唯一）
            $table->string('name', 150)->comment('名稱');
            $table->string('slug', 200)->unique()->comment('Slug');

            $table->string('cover_image_path', 255)->nullable()->comment('封面');

            $table->string('level', 50)->nullable()->comment('程度');
            $table->unsignedSmallInteger('duration_minutes')->nullable()->comment('時長');

            $table->string('summary', 500)->nullable()->comment('摘要');
            $table->longText('content')->nullable()->comment('內容');

            $table->unsignedInteger('sort_order')->default(0)->comment('排序');
            $table->boolean('is_active')->default(true)->comment('啟用');

            $table->timestamp('created_at')->nullable()->comment('建立');
            $table->timestamp('updated_at')->nullable()->comment('更新');
            $table->timestamp('deleted_at')->nullable()->comment('刪除');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('class_courses');
    }
};
