<?php

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

return new class extends Migration
{
    /**

    const STATUS_PENDIENTE = 'pendiente';
    const STATUS_PROCESO = 'proceso';
    const STATUS_PAGADO = 'pagado';
    const STATUS_FALLIDO = 'fallido';
     */
    public function up(): void
    {
        Schema::create('pagos', function (Blueprint $table) {
            $table->id();
            $table->integer('plans_id');
            $table->integer('folio');
            $table->integer('concepto');
            $table->integer('beca');
            $table->decimal('monto', 8, 2);
            $table->decimal('pago', 8, 2);
            $table->date('fecha_pago');
            $table->dateTime('fecha_pagado')->nullable();
            $table->unsignedBigInteger('user_id');
            $table->unsignedBigInteger('asignacion');
            $table->enum('status', ['pendiente','proceso','pagado','fallido'])->default('pendiente');

            $table->string('openpay_id')->nullable();
            $table->string('order_id')->nullable()->unique();
            $table->string('metodo_pago')->nullable();
            $table->string('referencia')->nullable();
            $table->timestamp('fecha_webhook')->nullable();

            $table->json('openpay_response')->nullable();

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

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