Laravel - Pagination - Appending Query String Values
You may append to the query string of pagination links using the appends
method. For example, to append sort=votes
to each pagination link, you should make the following call to appends
:
use App\Models\User;
Route::get('/users', function () {
$users = User::paginate(15);
$users->appends(['sort' => 'votes']);
//
});
You may use the withQueryString
method if you would like to append all of the current request's query string values to the pagination links:
$users = User::paginate(15)->withQueryString();