Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Query Filter

Query Filter Laravel Package

kblais/query-filter

A Laravel package for building reusable, request-driven query filters for Eloquent models. Map parameters to filter classes, keep controllers clean, and compose testable filtering logic without cluttering your queries.

View on GitHub
Deep Wiki
Context7

Define filters for your Eloquent models based on your request

Frequently asked questions about Query Filter
How do I install kblais/query-filter in a Laravel application?
Install it with Composer using composer require kblais/query-filter. Laravel package discovery should register the package automatically, so no manual service provider wiring is usually needed. Then define filter classes and map request parameters to them in the models or endpoints you want to filter. Before production rollout, confirm the package's Laravel and PHP version constraints in its composer.json and CI matrix.
What does kblais/query-filter do for Eloquent models?
It lets you define reusable filter classes for Eloquent models and drive them from request parameters. Instead of writing ad hoc query conditions in controllers, you map parameters to filters and compose the filtering logic in a testable way. It is intended for Laravel applications that use Eloquent or the query builder and want declarative, request-driven filtering.
Is kblais/query-filter compatible with Laravel 13?
Version 3.4.0 is described as adding Laravel 13 compatibility, so it is the release to evaluate if you are planning or testing Laravel 13. Confirm whether Laravel 13 is generally available for your use case and check the repository's CI matrix for the exact Laravel and PHP versions tested. Teams on older supported Laravel versions may not need to upgrade immediately unless they are keeping dependencies current.
Does upgrading to kblais/query-filter v3.4.0 introduce breaking changes?
The release notes for v3.4.0 indicate a compatibility-focused update with no breaking changes from v3.3.x. Treat it as a minor upgrade: update via Composer, run your full application test suite, and verify existing filter definitions behave identically. Pay particular attention to endpoint tests for allowed and denied filters, sorting, pagination, and relationship filters.
How do I test request-driven query filters in Laravel?
Add endpoint-level tests that cover allowed filters, denied filters, sorting, pagination, and relationship filtering. Because filter logic is composed in classes, you can also unit test individual filter definitions independently. Run these tests in a non-production branch before rolling the package out to low-risk read-only API endpoints first.
Are kblais/query-filter filters safe against SQL injection?
The TPM assessment flags SQL injection protections around dynamic filters as a residual review area, so do not treat filtering as automatically safe. Enforce allowlists for filterable columns, sort fields, and relationships, and validate every request parameter before it reaches a filter. Avoid accepting arbitrary column names or operators from user input, and add security tests for denied filters. Review your filter definitions and authorization rules alongside the package's behavior.
How do I keep Laravel controllers clean when adding query filters?
Define filter classes for the query behavior you need and map request parameters to those classes instead of embedding conditions in controller actions. Keep validation and authorization policies in your Laravel application layer so filters only run for permitted requests. This keeps controllers thin and makes the filtering logic reusable and testable across endpoints.
What performance risks should I check before using dynamic Eloquent filters in production?
Dynamic filtering can generate expensive queries, especially with complex relationship filters or broad filter combinations. Enforce allowlists, require pagination, set query timeouts, and monitor for slow queries before exposing filters on large datasets. Review query plans under representative filter combinations and pilot on a low-risk endpoint before wider rollout.
Is kblais/query-filter actively maintained and suitable for production use?
Support appears to be open-source and GitHub-driven, so production suitability depends on maintainer activity, release cadence, and a defined security disclosure process. The v3.4.0 release itself has a low failure profile because it is a compatibility-focused minor update. Teams should assign internal ownership for dependency updates, filter definitions, and security review, and confirm the tested Laravel and PHP matrix before adopting it broadly.
When should I use kblais/query-filter instead of custom Eloquent query scopes?
Use kblais/query-filter when you want declarative, reusable request-driven filters shared across Eloquent models and endpoints. Custom query scopes can be sufficient for simple, one-off filtering, but they often become harder to compose and test as filtering rules grow. The package complements your existing validation, authorization policies, and API resource layers rather than replacing them.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib