psampaz wrote a tutorial on how to paginate our custom data.

Custom data pagination

Let’s say that you have an array of data, e.g results from a search query, and you want to paginate them.

Laravel provides pagination for Eloquent results out of the box, but for custom data we need to do the pagination manually.