<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('signalements', function (Blueprint $table) {
            $table->id();
            $table->foreignId('mission_id')->constrained('missions');
            $table->foreignId('client_id')->constrained('clients');
            $table->enum('type_signalement', ['absence', 'retard', 'comportement', 'vol', 'degat', 'qualite', 'autre'])->notNull();
            $table->text('description')->notNull();
            $table->enum('gravite', ['faible', 'moyen', 'grave', 'critique'])->default('moyen');
            $table->enum('statut', ['recu', 'en_traitement', 'resolu', 'classe'])->default('recu');
            $table->foreignId('traite_par')->nullable()->constrained('users')->nullOnDelete();
            $table->text('resolution')->nullable();
            $table->timestamp('date_resolution')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('signalements');
    }
};
