<?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('transaksi_bukets', function (Blueprint $table) {
            $table->id('id_transaksi');
            $table->string('no_invoice')->unique(); // Contoh: INV-BKT-001

            // Foreign Keys
            $table->foreignId('id_pelanggan')->constrained('pelanggans', 'id_pelanggan')->onDelete('cascade');
            $table->foreignId('id_buket')->constrained('bukets', 'id_buket')->onDelete('cascade');

            $table->text('request')->nullable(); // Catatan khusus
            $table->text('ucapan')->nullable(); // Catatan khusus
            $table->dateTime('tgl_ambil');
            $table->decimal('total_bayar', 12, 2);
            $table->string('bukti_bayar')->nullable();

            // Enum Status Final
            $table->enum('status_transaksi', ['menunggu_verifikasi', 'diterima', 'ditolak', 'selesai', 'dibatalkan'])->default('menunggu_verifikasi');

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

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