Im calling this controller method from a search field. I need to check wether the entered value exists in city, state or zip fields in the database. But I'm getting the above error. How to resolve this?
public function search_x(Request $request)
{
$value = $request->input('search_daycare_zip');
$data1 = DB::select('SELECT * FROM daycares WHERE city = '.$value.'');
$data2 = DB::select('SELECT * FROM daycares WHERE state = '.$value.'');
$data3 = DB::select('SELECT * FROM daycares WHERE zip = '.$value.'');
if($data1 != null){
return view('daycare.daycares')->with('daycares',$data1);
}else if($data2 != null){
return view('daycare.daycares')->with('daycares',$data2);
}else if($data3 != null){
return view('daycare.daycares')->with('daycares',$data3);
}else{
return view('daycare.no_daycare');
}
// return 'done';
}enter code here