<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class RapportResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {  
   
        return [
            'id' => $this->id,
            'date_inspection' => $this->date_inspection,
            'classe_visitee' => $this->classe_visitee,
            'passation' => $this->passation,
            'titre_lecon' => $this->titre_lecon,
            'appreciation_generale' => $this->appreciation_generale,
            'note' => $this->note,
            'numero_ordre' => $this->numero_ordre,
            'nombre_eleve' => $this->nombre_eleve,
            'note' => $this->note,
            'present' => $this->present,
            'horaire' => $this->horaire,
            'deroulement' => $this->deroulement,
            'inspecteur' => [
                'id' => $this->inspecteur->id ?? null,
                'nomar' => $this->inspecteur->nomar ?? null,
                'nomfr' => $this->inspecteur->nomfr ?? null,

            ],
            'etablissement_id' => [
                'id' => $this->etablissement->id ?? null,
                'libellear' => $this->etablissement->libellear ?? null,
                'libellefr' => $this->etablissement->libellefr ?? null,
            ],
            'professeur_id' => [
                'id' => $this->professeur->id ?? null,
                'nomar' => $this->professeur->nomar ?? null,
                'nomfr' => $this->professeur->nomfr ?? null,
            ],
            'created_at' => $this->created_at,
        ];
    }
}
