Monday, April 3, 2017

search function with Where clause not work

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



via Mathieu Mourareau

Advertisement