<?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('SaranTanggapan', function (Blueprint $table) {
            $table->id('TanggapanID');
            $table->unsignedBigInteger('KegiatanID');
            $table->string('Nama', 100);
            $table->enum('Peran', ['masyarakat', 'lsm', 'akademisi', 'pemerintah']);
            $table->string('NIK', 16);
            $table->string('NoTelepon', 20);
            $table->string('Email', 100);
            $table->enum('Gender', ['laki-laki', 'perempuan']);
            $table->text('KondisiLingkungan');
            $table->text('NilaiLokal');
            $table->text('Kekhawatiran');
            $table->text('Harapan');
            $table->tinyInteger('TingkatKekhawatiran')->comment('1-5 scale: 1=sangat khawatir, 5=sangat berharap');
            $table->string('FotoSelfie', 255)->nullable();
            $table->enum('Status', ['pending', 'approved', 'rejected'])->default('pending');
            $table->text('CatatanAdmin')->nullable();
            $table->timestamp('TanggalDiajukan')->useCurrent();
            $table->timestamp('TanggalDiproses')->nullable();
            $table->timestamps();

            $table->foreign('KegiatanID')->references('KegiatanID')->on('InformasiKegiatan')->onDelete('cascade');
            $table->index(['KegiatanID', 'Status']);
            $table->index(['Peran', 'Status']);
            $table->index('TanggalDiajukan');
        });
    }

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