for pagination check it
https://laravel.com/docs/5.6/pagination https://laravel.com/docs/5.6/queries // skip(), take();
adn this one
https://laravel.io/forum/12-19-2014-get-sum-of-column-where-an-id-matches
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Guys iam working with a project.
This is my controller
$xcess_milks = Excess_milk::get();
return $xcess_milks;
this my ajax
<script type="text/javascript">
success:function(data)
{
var res='';
$.each (data, function (key, value) {
res +=
'<tr>'+
'<td>'+value.date+'</td>'+
'<td>'+value.time+'</td>'+
'<td>'+value.no_of_litre+'</td>'+
'<td>'+value.note+'</td>'+
'<td>'+ "<a href='{{ route('Excess_milk.show',$ex->id) }}' class='btn btn-info' style='width: 40%; float:left; margin-right:5px;'>Edit</a>"+
"<a href='{{ route('Excess_milk.show',$ex->id) }}' class='btn btn-info' style='width: 30%; '>Delete</a>"
+'</td>'+
'</tr>';
});
$('tbody').html(res);
}
});
})
here iam just returning $xcess milk to the the ajax and palced it in the table row.
i need to pass the total value also the sum
$sumvalue=$xcess->sum('no_of_litre')
i need to sum this need to return it the ajax return and also need to paste it as last row?
How to do this??
and also how can i add pagination instead of get() in the controller.
kindly some one suggest please
@AbdulBazith if i understand correctly How to return more than one variable, you want to pass multiple values, so you can do like this
return response()->json(['content'=>$xcess_milks, 'second_data_name'=>'second_data_value']);
// return response()->json([data], $status_code); // $status_code = 200
and in js do
success:function(data)
{
data.content
data.second_data_name
}
Please or to participate in this conversation.