let's assume we have 11 items and we set 10 items per page so the second page will have 1 item, in this case the pagination in second page is not displayed but when add another item and the list becomes 12 and the second page has 2 items the pagination is displayed.
Controller:
$cities = City::orderBy('id', 'desc')->paginate(10);
return view('cities.home', compact('cities'));
View:
<div class="panel-body">
<div class="table-responsive panel panel-sky">
<table class="table table-striped table-hover">
<tr>
<th>#</th>
<th>Name</th>
<th>Created At</th>
<th>Action</th>
</tr>
@foreach($cities as $city)
<tr id="product">
<td></td>
<td></td>
<td></td>
<td>
<a href=""><i class="glyphicon glyphicon-edit action-icon"></i></a>
<a type="button" class="pointer" data-toggle="modal" data-target="#deleteModal" data-type="btn-danger" data-action="delete-product" data-id="" data-msg="Are you sure you want to delete this city?" data-title="Confirm Deletion">
<span class='glyphicon glyphicon-remove action-icon'></span>
</a>
</td>
</tr>
@endforeach
</table>
<div>
@if ($cities->total() > $cities->count())
<div class="col-md-12"><?php echo $cities->render(); ?> </div>
@endif
</div>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire