feat(clinic): enhance clinic listing with additional details and address information
- Updated the clinic API response to include new fields: title, phone, logo, images_clinic, doctors_count, city, state, 24_7, and field_working_days. - Modified the ClinicController to fetch and include city and state information based on the clinic's address. - Refactored the toListArray method in the Clinic entity to accept city and state parameters. - Added a new method in the ClinicRepository to retrieve city and province names for each clinic based on their address.
This commit is contained in:
@@ -252,8 +252,14 @@ class ClinicController extends BaseController
|
||||
$filters = $request->query->all();
|
||||
$result = $this->clinicRepo->findWithFilters($filters);
|
||||
|
||||
$clinicIds = array_map(fn(Clinic $c) => $c->getId(), $result['items']);
|
||||
$locations = $this->clinicRepo->findAddressLocations($clinicIds);
|
||||
|
||||
return $this->paginated(
|
||||
array_map(fn(Clinic $c) => $c->toListArray(), $result['items']),
|
||||
array_map(function (Clinic $c) use ($locations) {
|
||||
$loc = $locations[$c->getId()] ?? ['city' => null, 'state' => null];
|
||||
return $c->toListArray($loc['city'], $loc['state']);
|
||||
}, $result['items']),
|
||||
$result['total'],
|
||||
$result['page'],
|
||||
$result['limit']
|
||||
|
||||
Reference in New Issue
Block a user