Getting Paginator pages - Am I doing the right thing?
Hey there, I'm working with pagination and I couldn't find a way to set the current page to whatever I wanted to.
Looking at the builder method I got to the following solution:
//current page = 1
$page = 3
$products = Product::paginate(10,['*'],null,$page);
But in my opinion I just have to send too much information that I'm not actually using to get to the page parameter.
Is there a better way to do this?
There are a few options you can handle this:
- Stick with
Product::paginate(10); and just start from page 1. If you need to navigate to page 3, just click the number '3'
-
Stick with what you have got, since the current page is the last parameter, you really can't do anything about it
-
Change the URL of your link to have ?page=3 at the end.
Please or to participate in this conversation.