<?php
/*=========================================================================================
    App Name  : PPID PTUN Kupang
    File Name : menus
    --------------------------------------------------------------------------------------
    Author    : Fuad Auliya Rohman
    Email     : fuad.dev16@gmail.com
==========================================================================================*/

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('menu_types', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->string('url')->nullable();
            $table->string('options')->nullable();
            $table->enum('status', ['Y', 'N']);
        });

        Schema::create('menus', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('parent_id')->default(0);

            $table->unsignedBigInteger('menu_type_id');
            $table->foreign('menu_type_id')->references('id')->on('menu_types')->onUpdate('restrict')->onDelete('restrict');

            $table->string('label');
            $table->string('url');
            $table->enum('target', ['_blank', '_self', '_top']);
            $table->tinyInteger('sequence')->default(0);
            $table->enum('status', ['Y','T'])->default('Y');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('menu_types');
        Schema::dropIfExists('menus');
    }
};
