<?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
    {
        Schema::create('honorarios', function (Blueprint $table) {
            $table->id();
            $table->decimal('monto', $precision = 20, $scale = 2); //monto 7
            $table->integer('porcentaje'); //monto 7
            $table->enum('activo', ['0','1','2'])->default(1);
            $table->bigInteger('registro_id')->unsigned()->nullable();
            $table->bigInteger('tipo_honorario_id')->unsigned()->nullable();
            $table->bigInteger('tasa_id')->unsigned()->nullable();
            $table->timestamps();
            $table->foreign('registro_id')->references('id')->on('registros')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('tipo_honorario_id')->references('id')->on('tipo_pagos')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('tasa_id')->references('id')->on('tasas')->onDelete('cascade')->onUpdate('cascade');
        });
    }

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