feat: enhance doctor address management by including clinic addresses and enforcing required fields

This commit is contained in:
hamed
2026-06-13 18:30:06 +03:30
parent c1c57df4ff
commit d05c070661
5 changed files with 289 additions and 21 deletions
+12 -2
View File
@@ -676,9 +676,19 @@ class DoctorController extends BaseController
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'دکتر یافت نشد', 404);
}
$addresses = array_map(fn(DoctorAddress $a) => $a->toArray(), $doctor->getAddresses()->toArray());
$personalAddresses = array_map(
fn(DoctorAddress $a) => $a->toArray(),
$doctor->getAddresses()->toArray()
);
return $this->success(['data' => $addresses]);
$clinicAddresses = [];
foreach ($this->clinicRepo->findByDoctor($doctor) as $clinic) {
foreach ($this->addressRepo->findBy(['clinicId' => $clinic->getId()]) as $addr) {
$clinicAddresses[] = $addr->toArray($clinic->getName());
}
}
return $this->success(['data' => array_merge($personalAddresses, $clinicAddresses)]);
}
// ── Helpers ───────────────────────────────────────────────────────────────