spatie/laravel-query-builder
Safely build Eloquent queries from incoming API requests. Allowlist filters, sorts, includes, and fields; supports partial/exact and custom filters, nested relationships, relation counts, and default values. Works with existing queries for clean, consistent endpoints.
This package doesn't provide any methods to help you paginate responses. However as documented above you can use Laravel's default paginate() method.
If you want to completely adhere to the JSON API specification you can also use our own spatie/json-api-paginate!
By default the query parameters wont be added to the pagination json. You can append the request query to the pagination json by using the appends method available on the LengthAwarePaginator.
$users = QueryBuilder::for(User::class)
->allowedFilters('name', 'email')
->paginate()
->appends(request()->query());
How can I help you explore Laravel packages today?