feat(search): enhance user search functionality to support Persian digits and user IDs
This commit is contained in:
@@ -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 !== '') {
|
||||
|
||||
Reference in New Issue
Block a user