Laravel - Get filtered data from SQL and using infinite Scroll Pagination - after scrolling i still get all the data

Viewed 154

When Im using Laravel pagination with infinite Scroll Pagination and im also getting my data from SQL after sort and filtering, when im refresh the page i get the correct data, but after scrolling im still get all the data from my DB instead getting only the filtered data

the javascript ajax when scroll down

the controller with the ajax handler

1 Answers

Instead of

->paginate(8);

try

->paginate(8, ['*'], 'page', $request->get('page'));

Actually I didn't found this in official docs, but here is the "paginate" method's default definition on their github repo.

Related