feat(search): enhance user search functionality to support Persian digits and user IDs

This commit is contained in:
hamed
2026-08-04 09:53:31 +03:30
parent cf0ca23f82
commit 654c1e8303
4 changed files with 341 additions and 3 deletions
+14 -2
View File
@@ -226,8 +226,20 @@ class AdminApiController extends BaseController
->from(User::class, 'u');
if ($search !== '') {
$qb->andWhere('u.mobileNumber LIKE :s OR u.realName LIKE :s OR u.email LIKE :s')
->setParameter('s', '%' . $search . '%');
// Persian/Arabic digits are what an admin actually types into the box; normalise
// them so both the mobile LIKE and the numeric user-id match behave.
$search = InputValidator::toEnglishDigits($search);
// A digits-only term is ambiguous: it can be a user id (#123) or part of a
// mobile number, so match either.
if (ctype_digit($search)) {
$qb->andWhere('u.id = :sid OR u.mobileNumber LIKE :s OR u.realName LIKE :s OR u.email LIKE :s')
->setParameter('sid', (int) $search);
} else {
$qb->andWhere('u.mobileNumber LIKE :s OR u.realName LIKE :s OR u.email LIKE :s');
}
$qb->setParameter('s', '%' . $search . '%');
}
if ($role !== '') {