I think the answer is simple: Use the paginate
method of Laravel.
I always use this in my applications to do a "paging" (actually what I do is a load on demand, using the Laravel paging logic).
What you need to understand is that the laravel pagination works by passing the page
parameter to the url query.
That is:
Route::get('/api/users', function () {
return User::paginate(10); // vai exibir de 10 em 10
});
In jQuery, you make your logic for parameter page
to be dynamically added:
var page = 1;
$.get('/api/users?page=' + page, function (response) {
});
If you change the value from page
to 2
, you would notice that the "next page" would load with the data you need. Knowing this, you can apply your logic freely.
Generally, what I usually do is an implementation with Angular and Inifinite Scroll.
I have a library where you can get more examples.