feat(patient): add search user functionality by mobile number
This commit is contained in:
@@ -37,6 +37,29 @@ class PatientController extends BaseController
|
||||
private readonly UserActiveContextRepository $contextRepo,
|
||||
) {}
|
||||
|
||||
#[Route('/api/v1/patient/search-user', methods: ['GET'])]
|
||||
public function searchUser(Request $request, #[CurrentUser] User $user): JsonResponse
|
||||
{
|
||||
[$entityType, $entityId] = $this->resolveEntity($user);
|
||||
$this->assertPatientGate($entityType, $entityId);
|
||||
|
||||
$mobile = trim($request->query->get('mobile', ''));
|
||||
if ($mobile === '') {
|
||||
return $this->error(ErrorCodes::ERR_VALIDATION_001, 'mobile الزامی است', 422);
|
||||
}
|
||||
|
||||
$patient = $this->userRepo->findByMobile($mobile);
|
||||
if ($patient === null) {
|
||||
return $this->error(ErrorCodes::ERR_NOT_FOUND_001, 'کاربری با این شماره یافت نشد', 404);
|
||||
}
|
||||
|
||||
return $this->success([
|
||||
'uuid' => $patient->getUuid(),
|
||||
'name' => $patient->getRealName(),
|
||||
'mobile' => $patient->getMobileNumber(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/patients', methods: ['GET'])]
|
||||
public function list(Request $request, #[CurrentUser] User $user): JsonResponse
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user