PHPackages                             coliving/eloquent-filter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. coliving/eloquent-filter

ActiveLib[Database &amp; ORM](/categories/database)

coliving/eloquent-filter
========================

The Eloquent Filter is a package for filter data of models by the query string. Easy to use and fully dynamic.

3.0.0(4y ago)04.0kMITPHPPHP ^7.3|^8.0|^8.1

Since Nov 8Pushed 4y agoCompare

[ Source](https://github.com/dungnh/eloquent-filter)[ Packagist](https://packagist.org/packages/coliving/eloquent-filter)[ Docs](https://github.com/mehdi-fathi/eloquent-filter)[ Fund](https://raw.githubusercontent.com/mehdi-fathi/eloquent-filter/master/donate.png)[ RSS](/packages/coliving-eloquent-filter/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (11)Versions (183)Used By (0)

Eloquent Filter [![Tweet](https://camo.githubusercontent.com/cb820a0ecc9645168e33b03925d7f14691262ddbaeaf66a0a91697803d0cba2d/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c2f687474702f736869656c64732e696f2e7376673f7374796c653d736f6369616c)](https://twitter.com/intent/tweet?text=Eloquent%20Filter%20adds%20custom%20filters%20to%20your%20Eloquent%20Models%20in%20Laravel%26url%3Dhttps%3A%2F%2Fgithub.com%2Fmehdi-fathi%2Feloquent-filter%26via%3Dmehdi-fathi%26hashtags%3Dlaravel%2Celoquent%2Cphp%2Cmysql%2Cdatabase%2Celoquentfilter)
=======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#eloquent-filter-)

[![alt text](./eloquent-filter.jpg "eloquent-filter")](./eloquent-filter.jpg)

[![Latest Stable Version](https://camo.githubusercontent.com/a67c0e7830a32686c053de1f817131ac3d343bc5b4634e81cafae8564106a973/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d656864692d66617468692f656c6f7175656e742d66696c746572)](https://packagist.org/packages/mehdi-fathi/eloquent-filter)[![Run tests](https://github.com/mehdi-fathi/eloquent-filter/workflows/Run%20tests/badge.svg?branch=master)](https://github.com/mehdi-fathi/eloquent-filter/workflows/Run%20tests/badge.svg?branch=master)[![License](https://camo.githubusercontent.com/fabab79a6f45c55904b42892962188070f2bf1d2cd8106b13249d9e18a92297b/68747470733a2f2f706f7365722e707567782e6f72672f6d656864692d66617468692f656c6f7175656e742d66696c7465722f6c6963656e7365)](https://packagist.org/packages/mehdi-fathi/eloquent-filter)[![GitHub stars](https://camo.githubusercontent.com/4f3d8b1a67ec71787e130831b678af7520b5ee3395aa56c0e79ad03ded56d2ae/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6d656864692d66617468692f656c6f7175656e742d66696c746572)](https://github.com/mehdi-fathi/eloquent-filter/stargazers)[![StyleCI](https://camo.githubusercontent.com/65376ab29f7c32c86fe8454b68c1f1cdd4d3631c430f4efa5f4f102a8931bc4a/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3134393633383036372f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/149638067)[![Build Status](https://camo.githubusercontent.com/eaac0084b226040a8bdecf493339b4bcf44e2baccd3b171839742d949a63fbbe/68747470733a2f2f7472617669732d63692e6f72672f6d656864692d66617468692f656c6f7175656e742d66696c7465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mehdi-fathi/eloquent-filter)[![Monthly Downloads](https://camo.githubusercontent.com/0cef8f8e41b6f88dc59b8f4e16a713475e7b55965e6ae60f5eb5eea58c76ccff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6d656864692d66617468692f656c6f7175656e742d66696c7465723f636f6c6f723d626c7565)](https://packagist.org/packages/mehdi-fathi/eloquent-filter)

Eloquent Filter adds custom filters to your Eloquent Models in Laravel. It's easy to use and fully dynamic.

[![Bitcoin Donate Button](https://camo.githubusercontent.com/7d4af88ec6fcc46d824314f23116eedab03c711908c4156afa74343c74ae6661/687474703a2f2f4b72697374696e697461546573742e6769746875622e696f2f646f6e6174652f426974636f696e2d446f6e6174652d627574746f6e2e706e67)](https://www.bitcoinqrcodemaker.com/api/?style=bitcoin&address=bc1qqzhw9euweyz28mtgqyjt703zzypyjxgxrxjgvm "eloquent-filter")

Table of Content
----------------

[](#table-of-content)

- [Introduction](#Introduction)
- [Installation](#Installation)
- [Basic Usage](#Basic-Usage)
    - [Config Model](#Config-Model-and-set-whitelist)
    - [Use in Controller](#Use-in-Controller)
    - [Simple Examples](#Simple-Examples)
    - [Custom Query Filter](#Custom-query-filter)
    - [Custom Detection Condition](#Custom-Detection-Condition)
- [Configuring](#Configuring)
    - [Publish Config](#Publish-Config)
    - [Config](#Config)
- [Magic Methods](#Magic-Methods)
    - [Request Filter](#Request-filter)
    - [Response Filter](#Response-filter)

Requirements
------------

[](#requirements)

- PHP 7.2+, 8.0, 8.1 (new version)
- Laravel 5.8+,6.x,7.x,8.x,9.x(prefer-stable)

🎤 Introduction
--------------

[](#microphone-introduction)

Let's say we want to make an advanced search page with multiple filter option params.

[![alt text](https://raw.githubusercontent.com/mehdi-fathi/mehdi-fathi.github.io/master/eloquent-filter/assets/img/Esfand-05-1399%2022-23-21.gif "sample 1 eloquent-filter")](https://raw.githubusercontent.com/mehdi-fathi/mehdi-fathi.github.io/master/eloquent-filter/assets/img/Esfand-05-1399%2022-23-21.gif)

### A simple implementation without Eloquent Filter

[](#a-simple-implementation-without-eloquent-filter)

The Request URI could look like this:

```
http://localhost:8000/users/index?age_more_than=25&gender=male&created_at=25-09-2019

```

And a simple implementation in the Controller would look like this:

```
