<?php

namespace App\Http\Requests;

use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log;

class StoreRapportRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        // Log user authentication status
        Log::info('StoreRapportRequest: Authorization check', [
            'authenticated' => auth()->check(),
            'user_id' => auth()->id(),
            'user_email' => auth()->user()?->email,
            'sanctum_token_valid' => auth()->guard('sanctum')->check(),
        ]);

        // Allow authenticated users via Sanctum
        return auth()->check();
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
   
        return [
            //
            'date_inspection'   => 'required|date',
            'classe_visitee'   => 'required|string|max:255',
            'passation'   => 'required|string|max:255',
            'titre_lecon'   => 'required|string|max:255',
            'deroulement'   => 'required|string|max:255',
            'appreciation_generale'   => 'required|string|max:255',
            'note'   => 'required|string|max:255',
            'nombre_eleve'   => 'required|string|max:255',
            'present'   => 'required|string|max:255',
            'horaire'   => 'required|string|max:255',
            'numero_ordre'   => 'required|string|max:255',
            'etablissement_id' => 'required|exists:etablissements,id',
            'professeur_id' => 'required|exists:professeurs,id',
            'inspecteur_id' => 'required|exists:inspecteurs,id'

        ];
    }
}
