I'm making a course on Laravel Sanctum: MasteringAuth.com

Creating a datatable with Laravel and InertiaJS

Constantin Druc ยท 25 Apr, 2021

If you check the code snippets you'll see I've added an additional method on the pagination call.

$query->paginate()->withQueryString();

The withQueryString() ensures the pagination links include whatever additional parameters we had in the original url (in our case search, field, and direction query params)