*/ public function toArray($request): array { return [ 'id' => $this->id, 'practitioner_id' => $this->practitioner_id, 'doc_type' => $this->doc_type, 'file_id' => $this->file_id, 'issue_date' => $this->issue_date?->format('Y-m-d'), 'expiry_date' => $this->expiry_date?->format('Y-m-d'), 'status' => $this->status, 'is_valid' => $this->is_valid, '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) ), ]; } }