<?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('izin_p1', function (Blueprint $table) {
            $table->id();
            $table->string('nosrt');
            $table->string('nim');
            $table->text('judul');
            $table->date('tanggal');
            
            // Checkboxes SPP
            for ($i = 1; $i <= 10; $i++) {
                $table->boolean('spp_' . $i)->default(false);
            }
            // Checkboxes KRS
            for ($i = 1; $i <= 10; $i++) {
                $table->boolean('krs_' . $i)->default(false);
            }
            
            $table->boolean('spi')->default(false);
            $table->boolean('spf')->default(false);
            $table->boolean('rekap_nilai')->default(false);
            
            $table->timestamps();
            
            $table->foreign('nim')->references('nim')->on('mahasiswa')->onDelete('cascade');
        });
    }

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