0
Hello, I’m having trouble with my Laravel research function
class PesquisaController extends Controller
{
public function pesquisaMonitoramento(Request $request, Monitoramento $mot)
{
$mot = $mot->newQuery();
if($request->has('id_mot')){
$mot->where('ID_CD_INTERNACAO',$request->get('id_mot'));
}
if($request->has('ds_paciente')){
$mot->where('ID_CD_PACIENTE',$request->get('ds_paciente'));
}
if($request->has('ds_convenio')){
$mot->where('ID_CD_CONVENIO',$request->get('ds_convenio'));
}
return $mot->get();
}
}
It’s a very simple function for testing, but it returns me nothing, returns an empty json, someone has some idea of the reason?
Within each
if
you need to program$mot = $mot->where('ID_CD_INTERNACAO',$request->get('id_mot'));
so you haven’t worked out.– novic
I just did that and I haven’t gotten the results, weird...
– André Tripode Colognesi
Within each if you have not updated the variable
$mot
with the new filter information, ie$mot = $mot->where('ID_CD_INTERNACAO',$request->get('id_mot'));
assign on all rows this... Although you should still have returned something if your table contains data...– novic
I already found the solution, the requests were going empty, so he wasn’t looking for anything, the question now is how to prevent him from sending the
– André Tripode Colognesi