*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'last_name' => $this->last_name, 'first_name' => $this->first_name, 'full_name' => trim($this->first_name . ' ' . $this->last_name), 'birth_date' => $this->birth_date ? $this->birth_date->format('Y-m-d') : null, 'death_date' => $this->death_date ? $this->death_date->format('Y-m-d') : null, 'place_of_death' => $this->place_of_death, 'notes' => $this->notes, 'documents_count' => $this->documents_count ?? $this->documents()->count(), 'interventions_count' => $this->interventions_count ?? $this->interventions()->count(), 'created_at' => $this->created_at->format('Y-m-d H:i:s'), 'updated_at' => $this->updated_at->format('Y-m-d H:i:s') ]; } }