добавил возможность поиска клиента по номеру в произвольном формате
This commit is contained in:
parent
e1f3b522bb
commit
ca37aa4776
@ -34,7 +34,8 @@ public function mount($status = null, $count = 10, $mode = 'full')
|
|||||||
$this->filter = [];
|
$this->filter = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function goToPage($page) {
|
public function goToPage($page)
|
||||||
|
{
|
||||||
$this->currentPage = $page;
|
$this->currentPage = $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ function getClients()
|
|||||||
$searchString = mb_strtolower(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}%")
|
$clients->orWhere('normalized_name', 'like', "%{$searchString}%")
|
||||||
->orWhere('normalized_phone', 'like', "%{$searchString}%")
|
->orWhere('normalized_phone', 'like', "%{$this->normilizePhone($searchString)}%")
|
||||||
->orWhere('email', 'like', "%{$searchString}%");
|
->orWhere('email', 'like', "%{$searchString}%");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +135,17 @@ function getClients()
|
|||||||
}
|
}
|
||||||
return $clients;
|
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()
|
public function render()
|
||||||
{
|
{
|
||||||
$clients = $this->getClients();
|
$clients = $this->getClients();
|
||||||
@ -151,5 +163,4 @@ public function render()
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user