How can I paginate a merged collection in Laravel 5?

however paginate is for eloquent models and DB queries, and not collections, it seems.

You are right. but there is ineed a paginator function for collections. forPage

Syntax:

Collection forPage(int $page, int $perPage)

Example:

Rest is simple.

public function foo()
{
    $collection = collect([1,2,3,4,5,6,7,8,9,0]);
    $items = $collection->forPage($_GET['page'], 5); //Filter the page var
    dd($items);
}

Leave a Comment