通常習慣作法是

  1. 在 route 中回傳 view('home')
  2. 在 view 當中執行腳本,使用 ajax/axios 去呼叫 API 獲取資訊
  3. 在 controller 中,若 SQL 指令包含 paginate(),回傳資訊就會包含分頁連結、分頁資訊
  4. 在 view 中把分頁連結綁定在上一頁/下一頁的按鈕上

參考

  1. https://www.webslesson.info/2018/09/laravel-pagination-using-ajax.html
  2. https://www.webslesson.info/2018/11/laravel-column-sorting-with-pagination-using-ajax.html
  3. https://stackoverflow.com/a/39629163
  4. https://stackoverflow.com/questions/39326206/pagination-for-search-results-laravel-5-3