{"repo":"Tucker-Eric/EloquentFilter","free":true,"listed":false,"github":"https://github.com/Tucker-Eric/EloquentFilter","clone":"git clone https://github.com/Tucker-Eric/EloquentFilter.git","description":"An Eloquent Way To Filter Laravel Models And Their Relationships","language":"PHP","stars":1764,"topics":["model-filters","eloquent-filters","dynamic-filters","relation-filter","laravel","eloquent","filter-logic","eloquent-models","filter","query"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Eloquent Filter An Eloquent way to filter Eloquent Models and their relationships. Introduction Lets say we want to return a list of users filtered by multiple parameters. When we navigate to: /users?name=er&last name=&company id=2&roles[]=1&roles[]=4&roles[]=7&industry=5 $request- all() will return: To filter by all those parameters we would need to do something like: To filter that same input With Eloquent Filters: Configuration Install Through Composer There are a few ways to define the filter a model will use: - Use EloquentFilter's Default Settings - Use A Custom Namespace For All Filters - Define A Model's Default Filter - Dynamically Select A Model's Filter Default Settings The default namespace for all filters is App\\ModelFilters\\ and each Model expects the filter classname to follow the {$ModelName}Filter naming convention regardless of the namespace the model is in. Here is an example of Models and their respective filters based on the default naming convention. Model ModelFilter ----- ----------- App\\User App\\ModelFilters\\UserFilter App\\FrontEnd\\PrivatePost App\\ModelFilters\\PrivatePostFilter App\\FrontEnd\\Public\\GuestPost App\\ModelFilters\\GuestPostFilter Laravel With Configuration File (Optional) Registering the service provider will give you access to the php artisan model:filter {model} command as well as allow you to publish the configuration file. Registering the service provider is not required and only needed if you want to change the default namespace or use ","default_branch":null,"files":null,"tree":[],"storefront":"/r/Tucker-Eric","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/Tucker-Eric/EloquentFilter/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."}