From f706c87cbcfda9c255fa6637c3382aa5a22e5c40 Mon Sep 17 00:00:00 2001 From: Mark Brule Date: Tue, 6 Jul 2021 20:43:17 +0000 Subject: [PATCH] wrap OR queries in sub-condition --- app/Http/Controllers/Api/AccessoriesController.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/AccessoriesController.php b/app/Http/Controllers/Api/AccessoriesController.php index edbf90d15c..0858489ee3 100644 --- a/app/Http/Controllers/Api/AccessoriesController.php +++ b/app/Http/Controllers/Api/AccessoriesController.php @@ -165,9 +165,13 @@ class AccessoriesController extends Controller if ($request->filled('search')) { $accessory_users = $accessory->users() - ->where('first_name', 'like', '%'.$request->input('search').'%') - ->orWhere('last_name', 'like', '%'.$request->input('search').'%') - ->get(); + ->where(function ($query) use ($request) { + $search_str = '%' . $request->input('search') . '%'; + $query->where('first_name', 'like', $search_str) + ->orWhere('last_name', 'like', $search_str) + ->orWhere('note', 'like', $search_str); + }) + ->get(); $total = $accessory_users->count(); }