<?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('pembayarans', function (Blueprint $table) {
            $table->id();
            $table->foreignId('mahasiswa_id')->constrained()->cascadeOnDelete();
            $table->string('nim');
            $table->foreignId('tahun_akademik_id')->constrained()->cascadeOnDelete();
            $table->string('semester');
            $table->decimal('nominal', 12, 2);
            $table->string('bukti_pembayaran')->nullable();
            $table->string('keterangan')->nullable();
            $table->string('kode_pembayaran', 8)->unique();
            $table->enum('status', ['pending', 'valid', 'invalid'])->default('pending');
            $table->enum('type', ['lunas', 'belum_lunas', 'cicilan'])->default('belum_lunas');
            $table->timestamps();
        });
    }

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