<?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('requests', function (Blueprint $table) {
            $table->id();
            $table->string('reference')->unique();
            $table->enum('type', ['Approvisionnement', 'Transfert']);
            $table->enum('status', ['en_attente', 'validée', 'rejetée'])->default('en_attente');
            $table->foreignId('department_id')->constrained('departments')->cascadeOnDelete('set null');
            $table->foreignId('user_id')->constrained('users')->cascadeOnDelete('set null');
            $table->foreignId('created_by')->constrained('users')->cascadeOnDelete('set null');
            $table->foreignId('approved_by')->constrained('users')->cascadeOnDelete('set null');
            $table->foreignId('rejected_by')->constrained('users')->cascadeOnDelete('set null');
            $table->text('comments')->nullable();
            $table->softDeletes();
            $table->timestamps();
        });
    }

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