<?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('orar_slots', function (Blueprint $table) {
            $table->id();
            $table->foreignId('clasa_id')->constrained('clase')->cascadeOnDelete();
            $table->foreignId('materie_id')->constrained('materii')->cascadeOnDelete();
            $table->string('zi'); // Luni, Marți, etc.
            $table->unsignedTinyInteger('ora_index'); // 0-based index
            $table->string('ora_inceput', 5); // HH:MM
            $table->string('ora_sfarsit', 5); // HH:MM
            $table->timestamps();

            $table->unique(['clasa_id', 'zi', 'ora_index']);
        });
    }

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