<?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('permohonan_projects', function (Blueprint $table) {
            $table->id();
            $table->string('judul_project');
            $table->string('bidang_sub_sektor_ekonomi_kreatif');
            $table->text('latar_belakang');
            $table->text('penerima_manfaat_pengguna_project');
            $table->text('solusi_project');
            $table->text('parameter_kesuksesan');
            $table->text('rincian_kebutuhan');
            $table->text('deskripsi_kolaborasi');
            $table->string('kata_kunci');
            $table->date('batas_terima_tawaran');
            $table->date('tanggal_mulai'); // Kolom untuk tanggal mulai
            $table->date('tanggal_berakhir'); // Kolom untuk tanggal berakhir
            $table->string('kategori'); // Kolom untuk kategori
            $table->string('kontak'); // Kolom untuk kontak
            $table->string('dokumen_pendukung')->nullable();
            $table->string('foto_proyek')->nullable(); // Kolom untuk foto proyek
            $table->foreignId('user_id')->constrained()->onDelete('cascade'); // Kolom untuk ID pengguna yang sedang input
            $table->boolean('checklist_komitmen')->default(false);
            $table->boolean('checklist_persetujuan')->default(false);
            $table->timestamps();
        });


        // Tabel Pelatihan
        Schema::create('permohonan_pelatihan', function (Blueprint $table) {
            $table->id();
            $table->foreignId('permohonan_project_id')->constrained('permohonan_projects')->onDelete('cascade');
            $table->text('audiens');
            // $table->decimal('biaya', 20, 2); 
            $table->integer('jumlah_peserta');
            $table->text('benefit_pelatihan');
            $table->text('lokasi_pelatihan');
            $table->string('status_pelatihan');
            $table->timestamps();
        });

        // Tabel Pendanaan
        Schema::create('permohonan_pendanaan', function (Blueprint $table) {
            $table->id();
            $table->foreignId('permohonan_project_id')->constrained('permohonan_projects')->onDelete('cascade');
            $table->decimal('jumlah_dana', 20, 2); 
            $table->text('lokasi_pendanaan');
            $table->text('rencana_penggunaan_dana'); //tidak perlu
            $table->string('status_pendanaan');
            $table->text('benefit_pendanaan');
            $table->timestamps();
        });

        // Tabel Riset
        Schema::create('permohonan_riset', function (Blueprint $table) {
            $table->id();
            $table->foreignId('permohonan_project_id')->constrained('permohonan_projects')->onDelete('cascade');
            // $table->decimal('anggaran', 20, 2);
            $table->string('lokasi_riset');
            $table->text('metodologi');
            $table->string('hasil');
            $table->string('status_riset');
            $table->text('benefit_riset');
            $table->timestamps();
        });

        // Tabel Proyek Investor  Details
        Schema::create('permohonan_project_investor', function (Blueprint $table) {
            $table->id();
            $table->foreignId('permohonan_project_id')->constrained('permohonan_projects')->onDelete('cascade');
            $table->decimal('nominal', 20, 2); 
            $table->text('rencana_implementasi');
            $table->string('status_project');
            $table->text('benefit_project');
            $table->string('lokasi_project');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('permohonan_project_investor_details');
        Schema::dropIfExists('permohonan_riset');
        Schema::dropIfExists('permohonan_pendanaan');
        Schema::dropIfExists('permohonan_pelatihan');
        Schema::dropIfExists('permohonan_projects');
    }
};
