добавил возможность поиска клиента по номеру в произвольном формате

This commit is contained in:
developer 2026-05-07 11:09:01 +08:00
parent e1f3b522bb
commit ca37aa4776

View File

@ -34,7 +34,8 @@ public function mount($status = null, $count = 10, $mode = 'full')
$this->filter = [];
}
public function goToPage($page) {
public function goToPage($page)
{
$this->currentPage = $page;
}
@ -119,7 +120,7 @@ function getClients()
$searchString = mb_strtolower(trim($this->filter['search']));
// $clients->whereFullText(['name', 'phone', 'email', 'normalized_name', 'normalized_phone'], $searchString);
$clients->orWhere('normalized_name', 'like', "%{$searchString}%")
->orWhere('normalized_phone', 'like', "%{$searchString}%")
->orWhere('normalized_phone', 'like', "%{$this->normilizePhone($searchString)}%")
->orWhere('email', 'like', "%{$searchString}%");
}
@ -134,6 +135,17 @@ function getClients()
}
return $clients;
}
private function normilizePhone($value)
{
$digits = preg_replace('/\D+/', '', $value);
if (strlen($digits) >= 2 && ($digits[0] === '7' || $digits[0] === '8')) {
return substr($digits, 1);
}
return $digits;
}
public function render()
{
$clients = $this->getClients();
@ -151,5 +163,4 @@ public function render()
]
);
}
}