$this->id, 'sample_number' => $this->sample_number, 'patient' => $this->whenLoaded('patient', function (){ return [ 'id' => $this->patient->id, 'uuid' => $this->patient->patient_uuid, 'name' => $this->patient->name_en ]; }), 'sample_source' => $this->whenLoaded('sample_source',function (){ return [ 'id' => $this->sample_source->id, 'name' => $this->sample_source->name_en ]; }), 'physician' => $this->whenLoaded('physician',function (){ return [ 'id' => $this->physician->id, 'name' => $this->physician->name_en ]; }), 'sample_details' => $this->whenLoaded('sample_details'), 'sample_tests' => $this->whenLoaded('sample_tests') ]; } }