While working with Laravel Vue and Algolia, I encountered an issue with pagination. The pagination seems to be functioning, but only the first page result is displayed. Clicking on pages 2, 3, etc. does not fetch the next page's results. Below are the steps I have taken:
SearchController.php
public function search(Request $request)
{
$error = ['error' => 'No results found, please try with different keywords.'];
if($request->has('q')) {
$movies = Movie::search($request->get('q'))->get();
return $movies ? $movies : $error;
}
return $error;
}
Pagination.js
var search = instantsearch({
appId: 'myid',
apiKey: 'mykey',
indexName: 'myindex',
urlSync: true
});
search.addWidget(
instantsearch.widgets.pagination({
container: '#pagination-container',
maxPages: 20,
scrollTo: false
})
);
search.start();