<?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('pay_bill', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('pay_type_id')->nullable();
            $table->unsignedBigInteger('company_id')->nullable();
            $table->unsignedBigInteger('user_id')->nullable();
            $table->unsignedBigInteger('bank_id')->nullable();  
            $table->date('pay_date');
            $table->decimal('amount', 10, 2);
            $table->string('id_card_number')->nullable();
            $table->string('reference')->nullable();
            $table->enum('status', ['Aprobado', 'Rechazado', 'Pendiente'])->default('Pendiente');
            $table->string('url_pay_imagen')->nullable();
            $table->boolean('is_full_input')->default(false);
            $table->integer('level_input')->nullable();

            $table->foreign('pay_type_id')->references('id')->on('pay_type')->onDelete('set null');
            $table->foreign('company_id')->references('id')->on('company')->onDelete('set null');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
            $table->foreign('bank_id')->references('id')->on('bank')->onDelete('set null');

            $table->timestamps();
        });
    }

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