Get last page in pagination

Hello all,
So I’ve setup a Livewire component that acts as infinite scrolling using pagination, it makes use of Livewire’s built-in functionality, I’m just wondering how would I go about getting the last page? I know Laravel has a method for it but I’m looking at Livewire’s WithPagination trait and I’m not seeing one. I’m not using actual links in my view either so I can’t really make use of the hasMorePages() method. I have some JS code that detects whether to go forward or back.
https://laravel.com/docs/7.x/pagination

Edit: The only thing I can think of is having some custom property that calculates the total number of pages based on how many results are shown.

Then put somewhere in your component a property like last-page="{{ $yourPaginatedItemList->lastPage() }}" and read this attribute from js code.

1 Like

You can take a look at the pagination docs.

I did. I found an alternative way as mentioned in my initial post by calculating the total number of records and how many results (per page) go into it. This isn’t really an ideal approach so I’ve decided to take another approach.

Happy to you for finding the solution by your own!
Keep the Great work @Haz.

Thiis is the solution. Why this wasn’t chosen?