fix(search): match Arabic ye/kaf with Persian letters in admin search
Customer names stored with ي/ك were missed when typing ی/ک; fold both sides of LIKE. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
/**
|
||||
* ی/ک عربی (ي ك ى) را با معادل فارسی یکی میکند تا جستجو و مقایسه قاطی نشود.
|
||||
*/
|
||||
class PersianText
|
||||
{
|
||||
public static function fold(string $value): string
|
||||
{
|
||||
return str_replace(['ي', 'ى', 'ك'], ['ی', 'ی', 'ک'], $value);
|
||||
}
|
||||
|
||||
/** عبارت SQL روی ستون مورد اعتماد (نه ورودی کاربر). */
|
||||
public static function sqlFoldExpr(string $sqlExpr): string
|
||||
{
|
||||
return "REPLACE(REPLACE(REPLACE({$sqlExpr}, 'ي', 'ی'), 'ى', 'ی'), 'ك', 'ک')";
|
||||
}
|
||||
|
||||
public static function likePattern(string $search): string
|
||||
{
|
||||
return '%'.self::fold($search).'%';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user