Ayman Hussein
Ayman Hussein

Reputation: 3857

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

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>    

Upvotes: 2

Views: 889

Answers (1)

user3253002
user3253002

Reputation: 1671

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!

Upvotes: 1

Related Questions