<?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('surat_pengantar_perkawinan', function (Blueprint $table) {
            $table->id();

            // Data Calon Mempelai Pria
            $table->string('nama_pria')->nullable()->comment('Nama lengkap calon mempelai pria');
            $table->string('nik_pria')->nullable()->unique()->comment('NIK calon mempelai pria');
            $table->string('tempat_lahir_pria')->nullable()->comment('Tempat lahir calon mempelai pria');
            $table->date('tanggal_lahir_pria')->nullable()->comment('Tanggal lahir calon mempelai pria');
            $table->string('agama_pria')->nullable()->comment('Agama calon mempelai pria');
            $table->string('pekerjaan_pria')->nullable()->comment('Pekerjaan calon mempelai pria');
            $table->text('alamat_pria')->nullable()->comment('Alamat lengkap calon mempelai pria');
            $table->string('status_perkawinan_pria')->nullable()->comment('Status perkawinan calon mempelai pria');
            $table->string('nama_ayah_pria')->nullable()->comment('Nama Ayah kandung calon mempelai pria');
            $table->string('nama_ibu_pria')->nullable()->comment('Nama Ibu kandung calon mempelai pria');

            // Data Calon Mempelai Wanita
            $table->string('nama_wanita')->nullable()->comment('Nama lengkap calon mempelai wanita');
            $table->string('nik_wanita')->nullable()->unique()->comment('NIK calon mempelai wanita');
            $table->string('tempat_lahir_wanita')->nullable()->comment('Tempat lahir calon mempelai wanita');
            $table->date('tanggal_lahir_wanita')->nullable()->comment('Tanggal lahir calon mempelai wanita');
            $table->string('agama_wanita')->nullable()->comment('Agama calon mempelai wanita');
            $table->string('pekerjaan_wanita')->nullable()->comment('Pekerjaan calon mempelai wanita');
            $table->text('alamat_wanita')->nullable()->comment('Alamat lengkap calon mempelai wanita');
            $table->string('status_perkawinan_wanita')->nullable()->comment('Status perkawinan calon mempelai wanita');
            $table->string('nama_ayah_wanita')->nullable()->comment('Nama Ayah kandung calon mempelai wanita');
            $table->string('nama_ibu_wanita')->nullable()->comment('Nama Ibu kandung calon mempelai wanita');

            // Detail Rencana Pernikahan
            $table->date('tanggal_rencana_nikah')->nullable()->comment('Tanggal rencana akad nikah');
            $table->string('tempat_rencana_nikah')->nullable()->comment('Tempat rencana akad nikah');

            // Dokumen Pendukung (sesuai gambar)
            $table->string('file_n1_path')->nullable()->comment('Path file Formulir N1');
            $table->string('file_n4_path')->nullable()->comment('Path file Formulir N4');
            $table->string('file_n5_path')->nullable()->comment('Path file Formulir N5 (jika usia < 21)'); // opsional
            $table->string('file_n6_path')->nullable()->comment('Path file Formulir N6 (Pernyataan Belum Menikah) - opsional'); // opsional
            $table->string('foto_ktp_pria_path')->nullable()->comment('Path foto KTP calon pria');
            $table->string('foto_kk_pria_path')->nullable()->comment('Path foto KK calon pria');
            $table->string('foto_ktp_wanita_path')->nullable()->comment('Path foto KTP calon wanita');
            $table->string('foto_kk_wanita_path')->nullable()->comment('Path foto KK calon wanita');
            $table->string('file_akta_lahir_pria_path')->nullable()->comment('Path file Akta Kelahiran calon pria');
            $table->string('file_akta_lahir_wanita_path')->nullable()->comment('Path file Akta Kelahiran calon wanita');
            $table->string('file_sertifikat_bimbingan_perkawinan_path')->nullable()->comment('Path file Sertifikat Bimbingan Perkawinan (optional)');


            // Informasi Surat
            $table->string('nomor_surat')->unique()->nullable()->comment('Nomor surat pengantar perkawinan');
            $table->date('tanggal_dikeluarkan')->nullable()->comment('Tanggal surat dikeluarkan');

            // Status Persetujuan
            $table->enum('status', ['menunggu_acc_admin_desa', 'disetujui', 'ditolak'])->default('menunggu_acc_admin_desa');
            $table->string('file_path')->nullable()->comment('Path file PDF surat yang sudah disetujui');
            $table->text('catatan_penolakan')->nullable()->comment('Catatan jika surat ditolak');
            $table->foreignId('disetujui_oleh')->nullable()->constrained('users')->nullOnDelete();
            $table->timestamp('tanggal_disetujui')->nullable();

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

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