From ca37aa4776aedeb50296e3ab4cbac74460906821 Mon Sep 17 00:00:00 2001 From: developer Date: Thu, 7 May 2026 11:09:01 +0800 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B8=D0=B5=D0=BD=D1=82=D0=B0=20=D0=BF=D0=BE=20=D0=BD=D0=BE?= =?UTF-8?q?=D0=BC=D0=B5=D1=80=D1=83=20=D0=B2=20=D0=BF=D1=80=D0=BE=D0=B8?= =?UTF-8?q?=D0=B7=D0=B2=D0=BE=D0=BB=D1=8C=D0=BD=D0=BE=D0=BC=20=D1=84=D0=BE?= =?UTF-8?q?=D1=80=D0=BC=D0=B0=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Livewire/ClientsTable.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/app/Livewire/ClientsTable.php b/app/Livewire/ClientsTable.php index 1462f18..5e94930 100644 --- a/app/Livewire/ClientsTable.php +++ b/app/Livewire/ClientsTable.php @@ -21,7 +21,7 @@ class ClientsTable extends Component { public $status; public $count; - public $mode;//short || full + public $mode; //short || full public $filter = []; public $clientsCount; public $currentPage; @@ -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; } @@ -100,7 +101,7 @@ function getClients() }) ->orderBy('deal_clients.id', 'desc') ->with('deals'); - $clients->select('users.id','users.name','users.phone','users.email'); + $clients->select('users.id', 'users.name', 'users.phone', 'users.email'); $clients->orderBy('name'); $clients->join('deals', 'deal_clients.deal_id', '=', 'deals.id'); if (array_key_exists('status', $this->filter)) { @@ -117,9 +118,9 @@ function getClients() if (array_key_exists('search', $this->filter) && $searchString = trim($this->filter['search'])) { $searchString = mb_strtolower(trim($this->filter['search'])); - // $clients->whereFullText(['name', 'phone', 'email', 'normalized_name', 'normalized_phone'], $searchString); + // $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}%"); } @@ -129,15 +130,26 @@ function getClients() }); } elseif (array_key_exists('status', $this->filter) && $this->status == DealStatus::NOT_UNIQUE) { $clients = $clients->whereHas('deals', function ($query) { - $query->whereIn('status', [DealStatus::MODERATION, DealStatus::NEW , DealStatus::NOT_UNIQUE]); + $query->whereIn('status', [DealStatus::MODERATION, DealStatus::NEW, DealStatus::NOT_UNIQUE]); }); } 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(); - $clients->groupBy('users.id','users.name','users.phone','users.email'); + $clients->groupBy('users.id', 'users.name', 'users.phone', 'users.email'); if ($this->clientsCount != $clients->count()) { $this->clientsCount = $clients->count(); $this->currentPage = 1; @@ -151,5 +163,4 @@ public function render() ] ); } - }