<?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
    {
        // 首页轮播图表
        if (! Schema::hasTable('sys_carousel')) {
            Schema::create('sys_carousel', function (Blueprint $table) {
                $table->increments('id');
                $table->string('title', 100)->comment('轮播图标题');
                $table->integer('image_id')->comment('轮播图图片信息（JSON）');
                $table->string('link', 500)->nullable()->default('')->comment('跳转链接');
                $table->unsignedTinyInteger('status')->default(0)->comment('状态：0=启用，1=禁用');
                $table->integer('sort')->default(0)->comment('排序（数字越大越靠前）');
                $table->timestamps();
                $table->comment('首页轮播图管理表');
            });
        }

        // 首页宫格导航表
        if (! Schema::hasTable('sys_grid_nav')) {
            Schema::create('sys_grid_nav', function (Blueprint $table) {
                $table->increments('id');
                $table->string('title', 100)->comment('导航标题');
                $table->integer('image_id')->comment('导航图标信息（JSON）');
                $table->string('link', 500)->nullable()->default('')->comment('跳转链接');
                $table->unsignedTinyInteger('status')->default(0)->comment('状态：0=启用，1=禁用');
                $table->integer('sort')->default(0)->comment('排序（数字越大越靠前）');
                $table->timestamps();
                $table->comment('首页宫格导航管理表');
            });
        }
    }

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