If the second page has one item, the pagination is not displayed in laravel 5.3

我的未来我决定 提交于 2019-12-07 22:30:16

问题


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{{$city->id}}">
                             <td>{{$city->id}}</td>
                             <td>{{$city->name}}</td>
                             <td>{{ $city->created_at }}</td>
                             <td>  
                                <a href="{{ url('product/' . $city->id . '/edit') }}"><i class="glyphicon glyphicon-edit action-icon"></i></a>
                                &nbsp;&nbsp;&nbsp;&nbsp;
                                <a type="button" class="pointer" data-toggle="modal" data-target="#deleteModal" data-type="btn-danger" data-action="delete-product" data-id="{{ $city->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>    

回答1:


After a lot of trying, I've found the solution:

update composer
php artisan vendor:publish --tag=laravel-pagination --force
php artisan view:clear

That's it!



来源:https://stackoverflow.com/questions/39303941/if-the-second-page-has-one-item-the-pagination-is-not-displayed-in-laravel-5-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!