Issues with Eloquent Pagination - link doesn't work

I have an issue with the Eloquent Pagination 5.4.

Lets say I have a table named comments containing 20 rows.
and the URL is www.site.com/comments

I am able to retrieve results using the paginate method on objects.
For example

Code example

$app→get(’/comments’, function(Request $request) {
$comments = \App\Models\Comment::paginate(5); // grab 5 comments from table
$comments->setPath(’’); // remove trailing slash from paginator

foreach ($comments as $comment) {
    echo $comment->title;
    echo "<br>";
}

});

This will retrieve 5 results that will show on www.site.com/comments as well as on /comments?page=1

My issue is, even when I change the page param to e.g. ?page=3 I still just see the same 5 comments as at =1.

It seems like the Eloquent Pagination totally ignores the ?page param. Possibly because I need to get it using e.g.$request->getParam('page'); But I have no clue what to do from there.

Anyone who has solved this problem?

I haven’t used Eloquent’s pagination outside of Laravel, but maybe have a look at this.