$this->id, 'sample_type' => new SampleTypeResource($this->whenLoaded('sample')), 'selected_organisms' => $this->whenLoaded('organisms', function() { return $this->organisms->map(function ($item){ return array( 'id' => $item->id, 'is_default' => $item->is_default, 'organism_id' => $item->organism_id, 'test_sample_id' => $item->test_sample_id, 'organism' => $item->organism, ); }); }), 'test_values' => $this->whenLoaded('testValues', function (){ return $this->testValues->map(function ($item){ return array( 'id' => $item->id, 'patient_type_id' => $item->patient_type_id, 'sign' => $item->sign, 'maximum' => $item->maximum, 'minimum' => $item->minimum ); }); }), 'test_id' => $this->test_id, 'heading_id' => $this->heading_id, 'usd_price' => $this->usd_price, 'group_result' => $this->group_result, 'category' => $this->category, 'unit_sign' => $this->unit_sign, 'weight' => $this->weight, 'field_type' => $this->field_type, 'format' => $this->format, 'formula' => $this->formula, 'description' => $this->description, 'organization_id' => $this->organization_id, 'code' => $this->code, 'is_bold' => (int) $this->is_bold, 'autocomplete_bind' => (int) $this->autocomplete_bind ]; } }