{"repo":"mohammad-fouladgar/eloquent-builder","free":true,"listed":false,"github":"https://github.com/mohammad-fouladgar/eloquent-builder","clone":"git clone https://github.com/mohammad-fouladgar/eloquent-builder.git","description":"This package provides an advanced filter for Laravel model based on incoming requets.","language":"PHP","stars":526,"topics":["laravel","eloquent","eloquent-filters","eloquent-builder","query-builder","larave-filters","laravel-query-filter","laravel-search"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Provides a Eloquent query builder for Laravel This package allows you to build eloquent queries, based on incoming request parameters. It greatly reduces the complexity of the queries and conditions, which will make your code clean and maintainable. Basic Usage Suppose you want to get the list of the users with the requested parameters as follows: In a common implementation, following code will be expected: But after using the EloquentBuilder , the above code will turns into this: You just need to define a filter for each parameter that you want to add to the query. Installation You can install the package via composer: Warning: The Lumen framework is no longer supported! Filters Namespace The default namespace for all filters is App\\EloquentFilters with the base name of the Model. For example, the filters' namespace will be App\\EloquentFilters\\User for the User model: Customize via Config file You can optionally publish the config file with: And set the namespace for your model filters which will reside in: Defining a Filter Writing a filter is simple. Define a class that extends the Fouladgar\\EloquentBuilder\\Support\\Foundation\\Contracts\\Filter abstract class. This class requires you to implement one method: apply . The apply method may add where constraints to the query as needed. Each filter class should be suffixed with the word Filter . For example, take a look at the filter defined below: Tip : Also, you can easily use local scopes in your filter. Because, they are inst","default_branch":null,"files":null,"tree":[],"storefront":"/r/mohammad-fouladgar","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/mohammad-fouladgar/eloquent-builder/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."}