Files
boursecu_server/app/Support/PersianText.php
T
mohmdsdgandCursor cae41e72b8 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>
2026-09-01 21:38:09 +03:30

26 lines
720 B
PHP

<?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).'%';
}
}