Level 75
I'm not understanding your question as results are in a collection anyway.
Is there a way to get pagination data inside collection?
return response()->
json(
User::with(['posts' => function($q) {
$q->paginate(5);
}, 'posts.comments' => function($q) {
$q->paginate(5, ['*'], 'commentsPage', request('commentsPage'));
}])
->where('username', request('username'))
->firstOrFail()
);
I need to pass this as well: $q->nextPageUrl() for posts
Please or to participate in this conversation.