Use appends() like the docs show to add additional custom parameters.
https://laravel.com/docs/5.7/pagination#displaying-pagination-results
{{ $users->appends(['sort' => 'votes'])->links() }}
add &sort=votes to pagination query string
In basic pagination we get some next url for loading more data, but if those data have more data with pagination as well, how can I customize and use different parameters for different data:
?page=2 to ?posts=2&comments=1
I am using api resource with main UserResource which returns posts with PostsResource which uses pagination and returns CommentsResource whicch uses pagination as well.
@SNAPEY - I am using api resource and its similar to yours:
'posts' => PostsResource::collection($this->posts()->paginate(1, ['*'], 'posts', $request->query('posts'))),
'total' => $this->posts()->paginate(1, ['*'], 'posts')->total(),
I am returning this from UserResource.
But since I am using resource and not collection because I cannot customize collection output, I cannot get pagination data only way I added above, is there any other way?
Please or to participate in this conversation.