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.
ValueError in query parameter parsing (#1055)delimiter() method on AllowedFilterFull Changelog: https://github.com/spatie/laravel-query-builder/compare/6.4.4...7.0.0
Add Laravel 13 support
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.4.0...6.4.1
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.3.6...6.4.0
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.3.5...6.3.6
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.3.4...6.3.5
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.3.3...6.3.4
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.3.2...6.3.3
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.3.1...6.3.2
.github folder and .php_cs from being included in composer installation by @stevebauman in https://github.com/spatie/laravel-query-builder/pull/993Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.3.0...6.3.1
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.2.3...6.3.0
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.2.2...6.2.3
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.2.1...6.2.2
pgsql driver in FiltersPartial - Fixes #941 by @Talpx1 in https://github.com/spatie/laravel-query-builder/pull/968Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.2.0...6.2.1
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.1.0...6.2.0
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.0.1...6.1.0
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/6.0.0...6.0.1
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/5.8.1...6.0.0
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/5.8.0...5.8.1
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/5.7.0...5.8.0
allowedFields. by @carvemerson in https://github.com/spatie/laravel-query-builder/pull/917unsetDefault as a replacement for default(null) which was removed in 5.6.0 by @patrickrobrecht in https://github.com/spatie/laravel-query-builder/pull/902defaultSort function as documented by @MajidMohammadian in https://github.com/spatie/laravel-query-builder/pull/904disable_invalid_includes_query_exception config option by @dimzeta in https://github.com/spatie/laravel-query-builder/pull/906AllowedFilter.php to include getFilterClass function by @justasSendrauskas in https://github.com/spatie/laravel-query-builder/pull/909Full Changelog: https://github.com/spatie/laravel-query-builder/compare/5.6.0...5.7.0
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/5.5.0...5.6.0
withExists via IncludedExists by @enricodelazzari in https://github.com/spatie/laravel-query-builder/pull/891QueryBuilder is used as a dependency in a package)Full Changelog: https://github.com/spatie/laravel-query-builder/compare/5.4.0...5.5.0
request_data_source config. The QueryBuilder will always look at both the query string and the request body when available nownull as the query parameter name for filters (see #889)Full Changelog: https://github.com/spatie/laravel-query-builder/compare/5.3.0...5.4.0
fields query parameter by @ezra-obiwale in https://github.com/spatie/laravel-query-builder/pull/872FiltersEndsWithStrict filter by @utsavsomaiya in https://github.com/spatie/laravel-query-builder/pull/885allowedSorts are always set (even when none are requested) @luilliarcec in https://github.com/spatie/laravel-query-builder/pull/865Full Changelog: https://github.com/spatie/laravel-query-builder/compare/5.2.0...5.3.0
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/5.1.2...5.2.0
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/5.1.1...5.1.2
array_diff_assoc BC break in v5.1.0 by @stevebauman in https://github.com/spatie/laravel-query-builder/pull/827Full Changelog: https://github.com/spatie/laravel-query-builder/compare/5.1.0...5.1.1
beginsWithStrict filter by @danilopinotti in https://github.com/spatie/laravel-query-builder/pull/821Full Changelog: https://github.com/spatie/laravel-query-builder/compare/5.0.3...5.1.0
plucked values (that are not a Model) is not possibleFull Changelog: https://github.com/spatie/laravel-query-builder/compare/4.0.3...4.0.4
${var} string interpolation deprecation by @Ayesh in https://github.com/spatie/laravel-query-builder/pull/779__invoke() method of Filter by @kayw-geek in https://github.com/spatie/laravel-query-builder/pull/781Full Changelog: https://github.com/spatie/laravel-query-builder/compare/5.0.2...5.0.3
Take a look at the upgrade guide for a more detailed explanation.
QueryBuilder (#621)WHERE clause for ambiguous partial filters (#567)WHERE clause for ambiguous exact filters (#467)InvalidFilterQuery exceptionInvalidFilterQuery exception (#525)AllowedFilter::filter()Illuminate\Database\Eloquent\Builder instead of a QueryBuilder instanceNew major version. Please read the UPGRADING guide before upgrading.
Spatie\QueryBuilder\QueryBuilder class no longer extends Laravel's Illuminate\Database\Eloquent\BuilderonlyTrashed) (#469)FiltersTrashed for filtering soft-deleted modelsFiltersCallback for filtering using a callbacknull includes (#395)defaultDirectionQueryBuilderRequest from service containerQueryBuilder::for()SortsFieldCount will add the related models' count using $query->withCount()Spatie\QueryBuilder\Sort to Spatie\QueryBuilder\AllowedSortSpatie\QueryBuilder\Included to Spatie\QueryBuilder\AllowedIncludeSpatie\QueryBuilder\Filter to Spatie\QueryBuilder\AllowedFilterFilter, Include and Sort interfaces no longer need to return the Builder instanceallowedFields should be called before allowedIncludeschunked query (#299)orderByRaw is no longer being rejected as a sorting option (#258)addSelect is no longer being replaced by the ?fields parameter (#260)allowedIncludes no longer adds duplicate includes for nested includes (#251)sort() method on QueryBuilderRequestallowedSorts and their aliasesallowedFieldsDO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
QueryBuilderRequest to read data from the current requestRequest::filters(), Request::includes(), etc...)DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
$filter->ignore()allowedFilters('related-model.name')DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
allowedIncludes with many-to-many relationships (#118)DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
allowedFields() but selecting noneDO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
allowedFields methodRequest::fields() macroSELECT * FROM table instead of SELECT table.* FROM table)DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
Filter::scope() for querying scopesDO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
allowedAppends()DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
?fields[table]=field_nameDO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
allowedIncludes, allowedFilters and allowedSorts to accept arraysDO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
_ and % in LIKE queries)DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
_ and % in LIKE queriesDO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
DO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
allowedSorts together with an empty sort query parameter no longer throws an exceptionDO NOT USE: THIS VERSION ALLOWS SQL INJECTION ATTACKS
Full Changelog: https://github.com/spatie/laravel-query-builder/compare/4.0.1...4.0.2
How can I help you explore Laravel packages today?