{"repo":"aldemeery/sieve","free":true,"listed":false,"github":"https://github.com/aldemeery/sieve","clone":"git clone https://github.com/aldemeery/sieve.git","description":"A simple, clean and elegant way to filter Eloquent models.","language":"PHP","stars":138,"topics":["laravel","eloquent","filter","filtration"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Sieve - Clean & Easy Eloquent Filtration Installation Usage Creating Filters Filtering Mapping Values A minimalist, ultra-lightweight package for clean, intuitive query filtering. With Sieve, your filtration logic is simplified from something like this: to this: --- Installation [!IMPORTANT] This package requires Laravel 11.0 or higher and PHP 8.2 or higher. You can install the package via composer: --- Usage Enabling filtration for a model is as easy as adding the Aldemeery\\Sieve\\Concerns\\Filterable trait to it: The Filterable trait introduces a filter local scope to your model, which accepts an associative array for filtration: Now you're ready to create your filter classes. --- Creating filters To create a filter, create a class that implements the Aldemeery\\Sieve\\Contracts\\Filter interface. You can either create a filter class using the make:filter artisan command, which will place the filter in the app/Http/Filters directory. Alternatively, you can create a filter class manually and place it wherever you prefer: This generates a ColorFilter class in the app/Filters/Product directory: Here, apply defines the filtration logic, while map can transform input values if needed before passing them to apply [!IMPORTANT] Before a value is passed to the apply method, it's first passed to the map method. If you do not need to map values into other values, you should just leave the map method as it is. Check out this examples: With an instance of Illuminate\\Database\\Eloquent\\Builder","default_branch":null,"files":null,"tree":[],"storefront":"/r/aldemeery","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/aldemeery/sieve/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}