{"repo":"pricecurrent/laravel-eloquent-filters","free":true,"listed":false,"github":"https://github.com/pricecurrent/laravel-eloquent-filters","clone":"git clone https://github.com/pricecurrent/laravel-eloquent-filters.git","description":"Advanced Laravel models filtering capabilities","language":"PHP","stars":176,"topics":["laravel","filter","eloquent"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Advanced Laravel models filtering capabilities Installation You can install the package via composer: Usage This package gives you fine-grained control over how you may go about filtering your Eloquent Models. This package is particularly good when you need to address complex use-cases, implementing filtering on many parameters, using complex logic. But let's start with simple example: Consider you have a Product, and you need to filter products by name : Generate eloquent-filter This will put your Filter to the app/Filters directory by default. You may prefix the name with the path, like Models/Product/NameFilter . You can use the --field=name argument to generate your filter with the field name Here is what your NameFilter might look like: Notice how our Filter has no clue it is tied up with a specific Eloquent Model? That means, we can simply re-use it for any other model, where we need to bring in the same name filtering functionality: You can chain methods from the filter as if it was simply an Eloquent Builder method: To enable filtering capabilities on an Eloquent Model simply import the trait Filterable More complex use-case This approach scales very well when you are dealing with a real-life larger applications where querying data from the DB goes far beyond simple comparison by a name field. Consider an app where we have Stores with a Location coordinates and we have products in stock and we need to query all products that are in stock in a store that is in 10 miles","default_branch":null,"files":null,"tree":[],"storefront":"/r/pricecurrent","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/pricecurrent/laravel-eloquent-filters/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."}