How can page through the results? .It With ajax. to bring the data to my view , I want to use paginate () and orderby (), but to put it is in the documentation , it generates error. if I do so : $cita= Cita::orderBy(asc)->paginate(10), I did not bring the data. Excuse the English 'm Mexican .
Controller:
public function agenda(){
$cita = Cita::all();
return Response()->json(
$cita->toArray()
);
}
Script:
function Carga(){
var tablaDatos = $("#datos");
var route = "http://cmec.app/agenda";
$("#datos").empty();
$.get(route, function(res){
$(res).each(function(key, value){
tablaDatos.append(
"<tr><td>"+value.name+"</td><td>"+value.lastname+"</td><td>"+value.doctor+"</td><td>"+value.fecha+"</td><td>"+value.hora+"</td><td><div class='btn-group btn-group-sm' role='group'><button value="+value.id+" OnClick='Mostrar(this);' class='btn btn-danger'><i class='fa fa-trash-o'></i></button><button value="+value.id+" OnClick='Mostrar(this); ' class='btn btn-primary' data-toggle='modal' data-target='#editar-modal' ><i class='fa fa-pencil-square'></i></button></div></td></tr>");
});
});}
Vista:
<table class="table table-hover">
<thead>
<tr>
<th>Nombre</th>
<th>Apellidos</th>
<th>Doctor</th>
<th>Fecha</th>
<th>Hora</th>
<th>Acciones</th>
</tr>
</thead>
<tbody id="datos"></tbody>
</table>
$cita= Cita::orderBy('asc')->paginate(10)
for pagination with order – Hitesh Siddhapurait generates error
" Please post the error message. – Jeemusu