- How do I install and set up thejano/laravel-filterable in a Laravel app?
- Install it with Composer using composer require thejano/laravel-filterable, then optionally publish the package configuration. Add the provided trait to the Eloquent model you want to filter and declare your filter classes. The integration is described as low-cost and mechanical, so a working pilot should take well under a day.
- Does Laravel Filterable support filtering by relationships and eager loading?
- The package overview states that it supports relationships and scopes alongside validation and custom logic. It is designed to compose with pagination and eager loading rather than replace them. However, because the README excerpt is empty here, verify the documented N+1 story and relationship filter behavior against your own query patterns.
- How does Laravel Filterable handle unknown query-string parameters and security?
- This is the highest-severity question in the evaluation. You must verify that filters are opt-in per model via an explicit allowlist rather than derived from arbitrary request keys. A package that maps any query-string key to a column effectively creates a SQL injection and index-scan vector, so test what happens on an unknown key: ignore, throw, or pass through.
- Which Laravel and PHP versions does thejano/laravel-filterable support?
- The provided context does not include the declared support matrix, so check the package composer.json and CI coverage before committing. Small packages can silently lag a major Laravel release, which can block a framework upgrade on a dependency you cannot patch upstream. Confirm support for your exact Laravel and PHP versions as a feasibility gate.
- Can I write custom filter logic and operator filters like range, in, like, and null?
- The package advertises custom logic and scope support, which suggests custom filter classes are the intended extension point. You should still verify whether it supports operator-typed filters such as range, in, like, and null with proper parameter binding. Also confirm whether any path concatenates raw SQL and whether custom logic requires forking.
- How do I test filter classes and query-string filtering in Laravel Filterable?
- Filter definitions are expressed as query-builder mutations, which makes them hard to unit test in isolation. Prefer feature tests that issue requests or apply filters to a real query builder and assert the resulting SQL, bindings, and returned records. The evaluation specifically asks whether tests ship with coverage on the filter-resolution path, so review that before relying on it.
- Is thejano/laravel-filterable safe and actively maintained for production use?
- The dominant risk is sustainability rather than code quality: roughly 75 stars, a low composite score, and a maintainer profile that is very likely a single individual. That means a bus factor of one on a component that will sit in the request path of every list endpoint. Mitigate cheaply by pinning the version, vendoring the source, and preparing a fork plan before adoption.
- What are alternatives to Laravel Filterable for filtering Eloquent models?
- The main alternative is hand-rolled scopeFilter methods scattered across models, which the package is meant to centralize and make reusable. You could also build dedicated query objects or filter classes yourself. For read models backed by Elasticsearch, Meilisearch, or Algolia, the package is a poor fit because it would add a second, divergent filtering dialect.
- Does Laravel Filterable work with pagination and API list endpoints?
- Yes, it is designed to compose with paginate, eager loading, and scopes, making it a natural fit for Laravel API backends where models are the system of record. It does not attempt to own HTTP, serialization, or response shaping. Keep in mind that filtering multiplies query shapes, so tie each filter to an index governance rule to avoid late latency regressions.
- How does thejano/laravel-filterable handle configuration and per-model filter allowlists?
- Configuration is optional to publish, and filters are declared as dedicated classes attached through a model trait. The key design check is whether those filters form an explicit opt-in allowlist per model rather than accepting arbitrary request keys. Encode which columns are filterable as policy in code, not convention, and confirm behavior for unknown keys before production use.