0
I have a table estagiario
related to a table areas
, and the table areas
in turn this related to the table departamento
.
I can even list all the interns used the following function:
public function index(){
$data = date("Y-m-d");
$terminados = Estagiario::whereDate('fim_estagio', '<=', $data)->paginate(6);
return view('estagiarios.terminado',compact('terminados'));
}
And I’m having trouble having interns who are associated with a certain department.
public function search(Request $request){
$search=$request->get('Departamento');
$data = date("Y-m-d");
$terminados =Estagiario::whereDate('fim_estagio', '<=', $data)
->where('areas.departamento.name','=', $search)
->paginate(6);
return view('estagiarios.terminado',compact('terminados'));
}
Please present the formatted code.
– Jorge Costa