Hey
I've an application that needs a paginated set of results. For now I'm using
MyModel::query()->someFilters()->paginate(perPage: 30);
So I end up with a length aware paginator. It works well. Now I need to limit the amount of total results, based on some user settings.
So let's take an example. I have a total of 1000 rows. My user only has the right to see 40 results, paginated by 30. I want to do something like the code above, but so that the query cannot get paginated results over the 40th. Which means it can have a total of 2 pages: the first one with 30 results and the second one with 10 results.
However, the take and limit methods aren't usable there as being erased for the pagination (which is not a bug, it's totally normal). How can we query such a thing?