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:
@@ -83,6 +83,40 @@ class ClinicRepository extends ServiceEntityRepository
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* City/province names for each clinic, taken from the clinic's address
|
||||
* (DoctorAddress.clinicId). Returns [clinicId => ['city' => ?string, 'state' => ?string]].
|
||||
*
|
||||
* @param int[] $clinicIds
|
||||
* @return array<int, array{city: ?string, state: ?string}>
|
||||
*/
|
||||
public function findAddressLocations(array $clinicIds): array
|
||||
{
|
||||
if ($clinicIds === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$rows = $this->getEntityManager()->createQueryBuilder()
|
||||
->select('addr.clinicId AS clinic_id', 'cityCat.name AS city', 'provinceCat.name AS state')
|
||||
->from(DoctorAddress::class, 'addr')
|
||||
->leftJoin('addr.city', 'cityCat')
|
||||
->leftJoin('addr.province', 'provinceCat')
|
||||
->where('addr.clinicId IN (:ids)')
|
||||
->setParameter('ids', $clinicIds)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
$map = [];
|
||||
foreach ($rows as $row) {
|
||||
$id = (int) $row['clinic_id'];
|
||||
if (!isset($map[$id])) {
|
||||
$map[$id] = ['city' => $row['city'], 'state' => $row['state']];
|
||||
}
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
public function save(Clinic $clinic, bool $flush = true): void
|
||||
{
|
||||
$this->getEntityManager()->persist($clinic);
|
||||
|
||||
Reference in New Issue
Block a user