specialities) { $specialities = SpecialityForHospitalDetailResource::collection($this->specialities); } else { $specialities = []; } return [ 'id' => $this->id, 'name' => $this->name, 'code' => $this->code, 'description' => $this->description, 'address' => $this->address ?? null, 'lat' => $this->lat, 'lng' => $this->lng, 'distance' => $this->distance ? ($this->distance < 1 ? round($this->distance * 1000, 2) . ' m' : round($this->distance, 2) . ' km') : null, 'city_name' => $this->city_name ?? null, 'rating' => rand(1, 100), 'phone' => $this->meta->phone, 'photo_url' => url('images/default-hospital-image.png'), 'photos' => [ 'title' => $this->name, 'photo_url' => url('images/default-hospital-image.png'), ], $this->mergeWhen($this->specialities, [ 'specialities' => $specialities ]) ]; } }