product autocomplate搜索关键字使用包含条件

This commit is contained in:
tim 2023-01-16 10:31:53 +08:00 committed by Edward Yang
parent 1b4c5bf027
commit b61c8cf9b6
1 changed files with 1 additions and 1 deletions

View File

@ -268,7 +268,7 @@ class ProductRepo
{
$products = Product::query()->with('description')
->whereHas('description', function ($query) use ($name) {
$query->where('name', 'like', "{$name}%");
$query->where('name', 'like', "%{$name}%");
})->limit(10)->get();
$results = [];
foreach ($products as $product) {