<?php

namespace App\Http\Resources;

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

class InspecteurResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        
        return [
            'id'         => $this->id, 
            'nomfr'      => $this->nomfr,
            'nomar'      => $this->nomar,
            'matricule'      => $this->matricule,
            'nni'      => $this->nni,
            'date_naissance'      => $this->date_naissance,
            'lieu_naissance_ar'      => $this->lieu_naissance_ar,
            'lieu_naissance_fr'      => $this->lieu_naissance_fr,
            'date_affectation'      => $this->date_affectation,
            'contact'      => $this->contact,
            'date_mise_en_corps_IES'      => $this->date_mise_en_corps_IES,
            'date_recri_fp'      => $this->date_recri_fp,
            'bank'      => $this->bank,
            'compte'      => $this->compte,
            'email'      => $this->email,
            'matrimonialite'      => $this->matrimonialite,
            'photo'      => $this->photo,
            'Bank'      => $this->Bank,
            'pole' => [
                'id' => $this->pole->id ?? null,
                'libellear' => $this->pole->libellefr ?? null,
                'libellefr' => $this->pole->libellear ?? null,
            ],
         
            'discipline' => [
                'id' => $this->discipline->id ?? null,
                'libelle' => $this->discipline->libelle ?? null,
            ],
            'created_at' => $this->created_at->format('d/m/Y H:i'),
        
         ];
    }
}
