<?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
    {
        // Tabel untuk penawaran_projects
        Schema::create('penawaran_projects', function (Blueprint $table) {
            $table->id();
            $table->string('judul_project');
            $table->string('bidang_sub_sektor_ekonomi_kreatif');
            $table->text('deskripsi_project');
            $table->enum('jenis_penawaran', ['pelatihan', 'pendanaan', 'riset']);
            $table->text('audiens');
            $table->date('batas_terima_tawaran');
            $table->string('kontak'); // Kolom untuk kontak
            $table->string('foto_proyek')->nullable();
            $table->string('status');
            $table->text('benefit');
            $table->unsignedBigInteger('user_id');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->timestamps();
        });

        // Tabel untuk penawaran_pelatihan
        Schema::create('penawaran_pelatihan', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('penawaran_project_id');
            $table->string('lokasi_pelatihan');
            $table->integer('durasi_pelatihan');
            $table->integer('jumlah_peserta');
            $table->foreign('penawaran_project_id')->references('id')->on('penawaran_projects')->onDelete('cascade');
            $table->timestamps();
        });

        // Tabel untuk penawaran_pendanaan
        Schema::create('penawaran_pendanaan', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('penawaran_project_id');
            $table->decimal('jumlah_dana', 20, 2);
            $table->foreign('penawaran_project_id')->references('id')->on('penawaran_projects')->onDelete('cascade');
            $table->timestamps();
        });

        // Tabel untuk penawaran_riset
        Schema::create('penawaran_riset', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('penawaran_project_id');
            $table->string('institusi_penelitian');
            $table->string('bidang_penelitian');
            $table->string('lokasi_riset');
            $table->text('metodologi');
            $table->string('hasil');
            $table->foreign('penawaran_project_id')->references('id')->on('penawaran_projects')->onDelete('cascade');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('penawaran_riset');
        Schema::dropIfExists('penawaran_pendanaan');
        Schema::dropIfExists('penawaran_pelatihan');
        Schema::dropIfExists('penawaran_projects');
    }
};
