<?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('menus', function (Blueprint $table) {
$table->id();
$table->string('name', 100);
$table->string('location', 100)->unique();
$table->timestamps();
});
Schema::create('menu_items', function (Blueprint $table) {
$table->id();
$table->foreignId('menu_id')->constrained()->cascadeOnDelete();
$table->foreignId('parent_id')->nullable()->constrained('menu_items')->nullOnDelete();
$table->json('title');
$table->string('url', 500)->nullable();
$table->foreignId('page_id')->nullable();
$table->string('target', 20)->default('_self');
$table->integer('sort_order')->default(0);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
public function down(): void {
Schema::dropIfExists('menu_items');
Schema::dropIfExists('menus');
}
};