feat: add clinic role support to doctor profile access and update API endpoint for clinic owners
This commit is contained in:
@@ -163,6 +163,39 @@ class DoctorController extends BaseController
|
||||
return $this->success(['data' => array_merge($doctor->toDetailArray(), ['clinics' => $clinicData])]);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/clinic/my-doctor/{doctorUuid}', methods: ['GET'])]
|
||||
#[IsGranted('ROLE_CLINIC')]
|
||||
public function showForClinic(string $doctorUuid, #[CurrentUser] User $user): JsonResponse
|
||||
{
|
||||
$clinic = $this->clinicRepo->findByUser($user);
|
||||
if ($clinic === null) {
|
||||
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'کلینیک یافت نشد', 404);
|
||||
}
|
||||
|
||||
$doctor = $this->doctorRepo->findByUuid($doctorUuid);
|
||||
if ($doctor === null) {
|
||||
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'پزشک یافت نشد', 404);
|
||||
}
|
||||
|
||||
if (!$clinic->getDoctors()->contains($doctor)) {
|
||||
return $this->error(ErrorCodes::ERR_AUTH_006, 'این پزشک عضو کلینیک شما نیست', 403);
|
||||
}
|
||||
|
||||
return $this->success(['data' => array_merge($doctor->toDetailArray(), ['clinics' => [[
|
||||
'id' => (string) $clinic->getId(),
|
||||
'uuid' => $clinic->getUuid(),
|
||||
'name' => $clinic->getName(),
|
||||
'address' => $clinic->getAddress(),
|
||||
'telephone' => $clinic->getTelephone(),
|
||||
'city_id' => $clinic->getCityId(),
|
||||
'province_id' => $clinic->getProvinceId(),
|
||||
'map' => [
|
||||
'latitude' => $clinic->getLatitude() !== null ? (string) $clinic->getLatitude() : null,
|
||||
'longitude' => $clinic->getLongitude() !== null ? (string) $clinic->getLongitude() : null,
|
||||
],
|
||||
]]])]);
|
||||
}
|
||||
|
||||
#[OA\Get(
|
||||
path: '/api/v1/doctors',
|
||||
summary: 'List doctors with optional filters (paginated)',
|
||||
|
||||
Reference in New Issue
Block a user