My controller
public function searchConsultants(Request $request,Consultant $conultant)
{
$location = $request->get('location');
$data = Consultant::where('location','LIKE','%'.$q.'%')->with('ratings')->get();
return response()->json($data);
}
My Jquery function
$.getJSON('/all-conultants', function(data) {
$.each(data, function(index) {
$('#consultantsData').append("<tr><td>"+data[index].id+"</td><td>"+data[index].cunsultant_name+"</td><td>"+data[index].contact_number+"</td><td>"+data[index].location+"</td></tr>");
});
});
Response Im getting with eager load
[{"id":1,"cunsultant_name":"ManjunatMj","contact_number":"9045685686","location":"Mumbai","department_id":1,
"ratings":[{"id":1,"customer_id":1,"consultant_id":1,"project_id":1,"sales_manager_id":1,"rating_for_project":1,"rating_for_manager":1,"created_at":"2017-07-21 06:34:05","updated_at":"2017-07-21 06:34:05"}]}]
I can display all details from same table, but how can I call relation in using jquery funtion.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2uFsF4E
via IFTTT
Aucun commentaire:
Enregistrer un commentaire