feat(patient): add search user functionality by mobile number

This commit is contained in:
hamed
2026-06-15 12:52:45 +03:30
parent 95f5918118
commit d13d8436ab
3 changed files with 153 additions and 4 deletions
@@ -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
{