Reputation: 1220
hello everyone i try to run a search query with a condition for my column 'structure_id' but when i run the query , it display me also results who are not from 'structure' = 4
here my query :
$search = $request->get('q');
return User::where(function($q) use($search) {
$q->where('name', 'like', '%' . $search .'%')
->orWhere('email', 'like', '%'.$search.'%')
->where('structure_id' , '=' , '4');
})->get();
someone have an idea to resolve this? thanks a lot in advance
Upvotes: 0
Views: 46
Reputation: 7421
change it to
$search = $request->get('q');
return User::where(function($q) use($search) {
$q->where('name', 'like', '%' . $search .'%')
->orWhere('email', 'like', '%'.$search.'%');
})
->where('structure_id' , '=' , '4')
->get();
Upvotes: 3