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:
2026-09-01 21:38:09 +03:30
co-authored by Cursor
parent e27a8ac397
commit cae41e72b8
5 changed files with 57 additions and 17 deletions
+25
View File
@@ -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).'%';
}
}