<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * Hak akses menu per grup (RPD §12.2 groups_menu). Relasi menu–group banyak-ke-banyak.
     */
    public function up(): void
    {
        Schema::create('menu_groups', function (Blueprint $table) {
            $table->foreignId('menu_id')->constrained()->cascadeOnDelete();
            $table->foreignId('group_id')->constrained()->cascadeOnDelete();
            $table->primary(['menu_id', 'group_id']);
        });
    }

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