Download the PHP package janakkapadia/filterable without Composer
On this page you can find all versions of the php package janakkapadia/filterable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download janakkapadia/filterable
More information about janakkapadia/filterable
Files in janakkapadia/filterable
Package filterable
Short Description Enhance your Laravel app with dynamic, customizable filtering for Eloquent models. This package provides an easy setup for multi-parameter filtering, custom logic, and relationship support—perfect for building flexible, data-driven features like admin panels and reports.
License MIT
Informations about the package filterable
Filterable Package
A custom Laravel package for dynamic filtering of models, built to simplify the process of filtering data in Laravel applications.
Installation
-
Install via Composer
Run the following command to add the package to your Laravel project:
-
Usage
This package provides a command to generate filter models dynamically.
Creating a New Filter Model:
-
Add Filter Trait to Your Model
-
Usage In Controller
Basic filtering:
With parentheses wrapping where conditions:
-
Request Example
To filter and sort the data, you can make a request like this:
-
Example Usage For Model Filter File
In your filter model (YourModelFilter.php), you can define both filter and sort methods:
-
Query Examples
Without parentheses (
filter()):With parentheses (
filter(true)):The parentheses version ensures proper grouping of conditions and can prevent unexpected results when combining multiple filters.
-
Advanced Features
- Parentheses Wrapping: Use
filter(true)to wrap where conditions in parentheses for complex queries - Filter Chaining: You can chain multiple filter operations together
- Separate Filter and Sort Fields: Define filterable fields in
$filtersarray and sortable fields in$sortarray
- Parentheses Wrapping: Use
