<?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('pengumpulan_tugas', function (Blueprint $table) {
            $table->id('id_pengumpulan');
            $table->unsignedBigInteger('id_tugas');
            $table->string('nisn', 20);
            $table->string('lampiran_tugas')->nullable();
            $table->datetime('tanggal_submit');
            $table->integer('exp')->default(0);
            $table->enum('status', ['dikumpulkan', 'terlambat', 'belum'])->default('belum');
            $table->timestamps();

            $table->foreign('id_tugas')
                  ->references('id_tugas')
                  ->on('tugas')
                  ->onDelete('cascade');
            
            $table->foreign('nisn')
                  ->references('nisn')
                  ->on('siswas')
                  ->onDelete('cascade');
        });
    }

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