<?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('menu_items', function (Blueprint $t) { $t->id(); $t->unsignedBigInteger('menu_id'); $t->unsignedBigInteger('parent_id')->nullable(); $t->unsignedSmallInteger('sort_order')->default(0); $t->enum('link_type', ['url','route','post','product_index','product_group','product','page']); $t->json('link_target')->nullable(); $t->string('icon', 60)->nullable(); $t->boolean('target_blank')->default(0); $t->enum('visible_when', ['always','authenticated','guest'])->default('always'); $t->boolean('is_mega')->default(0); $t->unsignedTinyInteger('mega_columns')->default(1); $t->timestamp('created_at')->nullable(); $t->timestamp('updated_at')->nullable(); $t->index(['menu_id', 'sort_order'], 'menu_items_menu_id_sort_order_index'); $t->index('parent_id', 'menu_items_parent_id_index'); $t->foreign('menu_id', 'menu_items_menu_id_foreign')->references('id')->on('menus')->onDelete('cascade'); $t->foreign('parent_id', 'menu_items_parent_id_foreign')->references('id')->on('menu_items')->onDelete('cascade'); }); } public function down(): void { Schema::dropIfExists('menu_items'); } }; 