Hello,
I would like to know if there is a simply way to generate a Json Pagination when building an API using Laravel 5.5.
I was trying to create a pagination using a framework called Framework 7 but it is so difficult(and I am running out of time),that I was hoping for another solution, having the pagination done via Json instead so I can simply pull these 3 below urls in my buttons without much logic:
"links": {
"self": "http://example.com/articles",
"next": "http://example.com/articles?page[offset]=2",
"last": "http://example.com/articles?page[offset]=10"
},
After researching a little bit on the internet I found this:
https://github.com/spatie/laravel-json-api-paginate
But this confused me, I am using the query builder(not Eloquent), and I thought that this:
https://laravel.com/docs/5.4/pagination#paginating-query-builder-results
would produce the correct pagination.
Could anyone please tell me if I really need the Spatie plugin or if there is a way to generate the json api and paginate it with the original plugin in Laravel 5.5 with perhaps something like:
return response()
->json($obj)
->paginate(15);
Thank you,