Exception or error:
Hi everyone I need help on how to make a query that will return the remaining data by 10 using Laravel pagination.
I have 15 numbers of data on my table, on first request it returns the first 10 data which is correct, but I need to get the remaining 5.
I doing this using jquery infinite scroll so I’m not showing any pagination or links/urls on my View
public function index()
{
$query = Task::whereDate('due', '<', date('Y-m-d'))
->where('task_phase_id', '<>', 4)
->where('task_status_id', '<>', 9)
->paginate(10);
dd($query);
}
Thanks in advance,
How to solve:
If you convert $query
to JSON, you’ll have an object with an attribute called next_page_url
(see the doc here).
It looks like http://laravel.app?page=2
.
You can then simply use this has your request URL with jQuery.
e.g : When you scroll to your page bottom, call next_page_url