<?php
namespace App\Http\Requests\Client;

use App\Enums\RolePrincipal;
use Illuminate\Foundation\Http\FormRequest;

class StoreSignalementRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->role === RolePrincipal::CLIENT;
    }

    public function rules(): array
    {
        return [
            'mission_id' => 'required|integer|exists:missions,id',
            'type_signalement' => 'required|string|in:absence,retard,comportement,vol,degat,qualite,autre',
            'description' => 'required|string|min:10|max:1000',
            'priorite' => 'nullable|string|in:basse,normale,haute,urgente',
        ];
    }

    public function messages(): array
    {
        return [
            'description.min' => 'La description doit contenir au moins 10 caractères.',
            'description.max' => 'La description ne peut pas dépasser 1000 caractères.',
        ];
    }
}
