- How do I install eloquent-filter/filter in a Laravel app?
- Install it with Composer using composer require eloquent-filter/filter, then add the package trait to the Eloquent model you want to filter and define a filter class for that model. The integration path is the standard Laravel request to controller to Eloquent flow, with no external service or datastore required. A proof of concept is typically measured in hours: install, configure, define one filter, and hit an endpoint.
- Which Laravel and PHP versions does eloquent-filter support?
- The supported Laravel and PHP versions are declared in the package's composer.json constraints, so check those before adoption rather than assuming compatibility. The package is described as Laravel-native and slots into the standard Eloquent query builder path. Because release cadence is rapid, verify the current version matrix against your application's Laravel and PHP versions.
- How does Eloquent Filter convert query string parameters into database queries?
- It uses a trait on Eloquent models plus an abstract filter class that resolves query-string parameters into filterBy* methods on the query builder. URLs such as ?name=jo&status=active become composable Eloquent query constraints instead of controller-level conditionals. The package is a thin convenience layer and does not introduce new infrastructure or a separate query engine.
- Is dynamic query-string filtering with Eloquent Filter safe in production?
- The main risk is the input surface: dynamic dispatch from query strings onto model filter methods can expose whatever filters exist unless you constrain it. The package does not make that allowlisting decision for you, so define an explicit allowlist and request-level validation at the application boundary. Treat the package as an HTTP-to-query translation layer, not as a security control.
- How do I create a custom filter class with eloquent-filter?
- Create a filter class that extends the package's abstract filter class and implements the filter methods that correspond to your allowed query parameters. Attach the package trait to the Eloquent model and point it at that filter class. Keep business logic in native Eloquent local scopes and have the filter class delegate to them so the package remains an adapter rather than the home of query semantics.
- Does eloquent-filter support filtering on Eloquent relationships?
- Relationship filtering behavior is not fully described in the provided context, so verify how relation filters are resolved before relying on them. The key questions are whether they use joins or lazy loading and what N+1 profile results. Test representative relation filters against real data and query logs before shipping them to a read API.
- Can I unit test Eloquent Filter logic without an HTTP request?
- Filter classes operate against the query builder, so well-structured filters should be testable by invoking them on a query builder in isolation rather than through a full HTTP request. Confirm this against the package's API and keep filter methods thin and delegated to Eloquent scopes. That approach also reduces coupling if you later replace the package.
- How does eloquent-filter handle pagination and sorting?
- The package maps query parameters onto query builder constraints, so pagination and sorting can be composed through the same mechanism. Composability is both the feature and the hazard: unbounded filter and sort combinations against unindexed columns, deep offset pagination, and count queries on large result sets can be expensive. The package provides no performance guardrails, so enforce limits and indexing in your application.
- What are alternatives to eloquent-filter for Laravel query filtering?
- Common alternatives include hand-written Eloquent local scopes, Spatie Query Builder, and Laravel Scout for search-oriented querying. Hand-written scopes are cheaper when the query surface is small and stable, while a query-param DSL helps when many endpoints need consistent filtering. Avoid running two query-param DSLs in one API, because that creates governance and maintenance problems.
- Is eloquent-filter actively maintained, and what is the bus factor risk?
- It is a single-maintainer project with a rapid release cadence; the latest release noted in the evaluation is dated 2026-02-27, which signals activity. The package has zero dependents, so there is no downstream ecosystem validation or transitive pressure hardening edge cases. The MIT license means you can fork and vendor it if upstream stalls, but that shifts long-term ownership risk onto your team.