joedawson's avatar

5.3 Pagination links rendered when unnecessary?

Hello everyone,

Within the backend of my application I paginate a lot of resources.

Before 5.3's release, when you rendered the links for pagination - they were never rendered if you only had one page, right? All of my applications below 5.3 definitely work this way.

Since upgrading one of my projects to 5.3, if a resource has a single page - i still displays the pagination (without any links because there aren't any).

Take my Comments for example. Here's what my view looks like, pretty basic.

<table class="table table-bordered table-striped">
    @include('admin.comments._thead')
    <tbody>
        @each('admin.comments._item', $comments, 'comment', 'admin.comments._empty')
    </tbody>
</table>

{{ $comments->links() }}

Now if there's no comments at all, my view looks like this.

Image here

Has anyone else experience this in 5.3? Where the links are rendered when unnecessary?

0 likes
7 replies
ConsoleTVs's avatar

You could perhaps count your variable, and if < than the number of items per page, hide the pagination

joedawson's avatar

@ConsoleTVs yeah I could do that - but I'm curious as to wether this was intentional and happens for other people. This change isn't in the release notes nor mentioned in the 5.3 documentation :/

bobbybouwmann's avatar

I have the same problem in a demo application. I will try to find the bug and file a pull request ;)

jekinney's avatar

The paginate collection has the total pages, amount per page and current page and current amount @ConsoleTVs just FYI there is a super easy way instead of a bunch of checks.

Please or to participate in this conversation.