PHPackages                             leonardjke/laravel-query-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. [Search &amp; Filtering](/categories/search)
4. /
5. leonardjke/laravel-query-filter

ActiveLibrary[Search &amp; Filtering](/categories/search)

leonardjke/laravel-query-filter
===============================

Laravel package for dynamically filtering Eloquent results using URL query string.

08PHP

Since Apr 26Pushed 6y ago1 watchersCompare

[ Source](https://github.com/leonardjke/laravel-query-filter)[ Packagist](https://packagist.org/packages/leonardjke/laravel-query-filter)[ RSS](/packages/leonardjke-laravel-query-filter/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Query Filter
====================

[](#laravel-query-filter)

Based on heroicpixels/filterable () This package gives you a convenient way to automatically filter Eloquent results based on query string parameters in the URL. Filterable parses the query string, compares it with columns that you'd like to automatically filter, then creates a dynamic scope that is used by Eloquent to construct the SQL.

- [Installation](#installation)
- [Copyright &amp; License](#license)
- [Usage](#usage)
    - [Single Value](#single-value)
    - [Multiple Values](#multiple-values)
    - [Multiple Parameters](#multiple-parameters)
    - [Boolean Operators](#boolean-operators)
    - [Comparison Operators](#comparison-operators)

Installation
====================================================

[](#installation)

Add the package to 'require' in your composer.json file:

```
"require": {
    "leonardjke/laravel-query-filter": "dev-master"
},

```

Run 'composer dump-autoload' from the command line:

```
#composer dump-autoload

```

License
=======

[](#license)

Copyright 2020 leonardjke

Released under MIT license (). See LICENSE file for details.

Usage
=====

[](#usage)

**Filterable.php**

```
class Object extends Eloquent {

   use Leonardjke\LaravelQueryFilter\Filterable;

}

```

The examples below use the Filterable class!

In the above example, class Object corresponds to table 'objects':

idcolorshapetotal1redsquare1502bluesquare20003greencircle5754yellowtriangle155redtriangle9006redtriangle600Filterable Columns
------------------

[](#filterable-columns)

Specify the column you want to automatically filter.

```
$columns = [ 'color', 'shape', 'total' ];

```

For example:

```
 http://www.your-site/?color=blue&shape=round&total=500

```

You can also alias the columns if you prefer not to reveal them:

```
$columns = [ 'col' => 'color', 'sha' => 'shape', 'tot' => 'total' ];

```

For example:

```
http://www.your-site/?col=blue&sha=round&tot=500

```

To filter results, simply pass the columns to Eloquent using filter():

```
$objects = Object::filter($requers)->get()->toArray();

```

The following examples demonstrate how query string parameters can be used.

Single Value
------------

[](#single-value)

```
?color=red

SELECT ... WHERE ... color = 'red'

```

idcolorshapetotal1redsquare1505redtriangle9006redtriangle600

Multiple Values
---------------

[](#multiple-values)

```
?color[]=red&color[]=blue

SELECT ... WHERE ... color = 'red' OR color = 'blue'

```

idcolorshapetotal1redsquare1502bluesquare20005redtriangle9006redtriangle600

Multiple Parameters
-------------------

[](#multiple-parameters)

```
?color[]=red&shape[]=triangle

SELECT ... WHERE ... color = 'red' AND shape = 'triangle'

```

idcolorshapetotal5redtriangle9006redtriangle600

Boolean Operators
-----------------

[](#boolean-operators)

```
?color[]=red&shape[]=triangle&bool[shape]=or

SELECT ... WHERE ... color = 'red' OR shape = 'triangle'

```

idcolorshapetotal4yellowtriangle155redtriangle9006redtriangle600

Comparison Operators
--------------------

[](#comparison-operators)

**Greater Than**

```
?total=599&operator[total]=>

SELECT ... WHERE ... total > '599'

```

idcolorshapetotal2bluesquare20005redtriangle9006redtriangle600**Less Than**

```
?total=600&operator[total]=<

SELECT ... WHERE ... total < '600'

```

idcolorshapetotal1redsquare1503greencircle5754yellowtriangle15**Not Equal**

```
?shape=triangle&operator[shape]=!=

SELECT ... WHERE ... shape != 'triangle'

```

idcolorshapetotal4yellowtriangle155redtriangle9006redtriangle600**Between (TODO)**

```
?total[start]=900&total[end]=5000

SELECT ... WHERE ... total BETWEEN '900' AND '5000'

```

idcolorshapetotal2bluesquare20005redtriangle900

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6551a2fbcafa58ed37141ae59bb8414b67c06ebf0a342d1425c23a203a769115?d=identicon)[leonardjke](/maintainers/leonardjke)

---

Top Contributors

[![leonardjke](https://avatars.githubusercontent.com/u/22217360?v=4)](https://github.com/leonardjke "leonardjke (10 commits)")

### Embed Badge

![Health badge](/badges/leonardjke-laravel-query-filter/health.svg)

```
[![Health](https://phpackages.com/badges/leonardjke-laravel-query-filter/health.svg)](https://phpackages.com/packages/leonardjke-laravel-query-filter)
```

###  Alternatives

[ruflin/elastica

Elasticsearch Client

2.3k50.4M203](/packages/ruflin-elastica)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15024.3M65](/packages/opensearch-project-opensearch-php)[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

934529.3k2](/packages/mailerlite-laravel-elasticsearch)[massive/search-bundle

Massive Search Bundle

721.4M13](/packages/massive-search-bundle)[outl1ne/nova-multiselect-filter

Multiselect filter for Laravel Nova.

45802.7k3](/packages/outl1ne-nova-multiselect-filter)[handcraftedinthealps/zendsearch

a general purpose text search engine written entirely in PHP 5

39921.0k35](/packages/handcraftedinthealps-zendsearch)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
