I created this function in my Controller to return a list of employees in my ajax request, but it is not returning anything.
public function getFuncionarios(Request $request){
if($info = Funcionario::where('id_empresa', $request->get('empresa'))){
return response()->json($info);
}else{
return 'error';
}
}
WhenIreturnthedirectvariableitalsodoesnotwork.
return$info;
ButifIputwhere
toreturnonly1recordworks.
$info=Funcionario::where('id_empresa',$request->get('empresa'))->first()
What can it be? What would be the right way to get the result I need? This list of employees would be to feed a <select>
.