*/ public function toArray($request): array { return [ 'id' => $this->id, 'first_name' => $this->first_name, 'last_name' => $this->last_name, 'full_name' => $this->full_name, 'email' => $this->email, 'phone' => $this->phone, 'job_title' => $this->job_title, 'hire_date' => $this->hire_date?->format('Y-m-d'), 'active' => $this->active, 'created_at' => $this->created_at?->format('Y-m-d H:i:s'), 'updated_at' => $this->updated_at?->format('Y-m-d H:i:s'), // Relations 'thanatopractitioner' => $this->when( $this->relationLoaded('thanatopractitioner'), new ThanatopractitionerResource($this->thanatopractitioner) ), ]; } }