Merge pull request #9797 from markbrule/fixes/search_parameter_checkedout_api

Fixed #9671: wrap OR queries in sub-condition in checkedout search
This commit is contained in:
snipe 2021-07-27 14:39:10 -07:00 committed by GitHub
commit 593e1234a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -171,9 +171,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();
}