Search code examples
phplaravel-5laravel-5.3

laravel DB:table for multi where AND Or condition for multiple slected field


My query like :

 $results = User::
  where('this', '=', 1)
->where('that', '=', 1)
->where('this_too', '=', 1)
->where('that_too', '=', 1)
->where('this_as_well', '=', 1)
->where('that_as_well', '=', 1)
->where('this_one_too', '=', 1)
->where('that_one_too', '=', 1)
->where('this_one_as_well', '=', 1)
->where('that_one_as_well', '=', 1)
->get();

Solution for the multi where condition in laravel ,because its not working currently


Solution

  •  ->where('twd.status','=','0')->where(function($q) use($data){
               $q->where('A','like', '%' .$data. '%')
              ->orWhere('B','like', '%' .$data. '%');
              ->orWhere('C','like', '%' .$search_param. '%'); 
         })