PHPackages                             stephenjude/simple-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. stephenjude/simple-query-filter

Abandoned → [spatie/laravel-query-builder](/?search=spatie%2Flaravel-query-builder)ArchivedLibrary[Search &amp; Filtering](/categories/search)

stephenjude/simple-query-filter
===============================

Easily filter eloquent model queries from HTTP requests

2.0.0(4y ago)321553MITPHPPHP ^8.0

Since Dec 15Pushed 3y ago1 watchersCompare

[ Source](https://github.com/stephenjude/simple-query-filter)[ Packagist](https://packagist.org/packages/stephenjude/simple-query-filter)[ Docs](https://github.com/stephenjude/simple-query-filter)[ RSS](/packages/stephenjude-simple-query-filter/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

Deprecation Notice
==================

[](#deprecation-notice)

This package is abandoned and no longer maintained. Consider using the [spatie/laravel-query-builder](https://github.com/spatie/laravel-query-builder) package instead.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#this-package-is-abandoned-and-no-longer-maintained-consider-using-the-spatielaravel-query-builder-package-instead)

Simple Query Filter
===================

[](#simple-query-filter)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3bbf03d079ac1aba1ac2621cb9c08e4d6b2ba2f77d532538536ba14385d9a5d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7374657068656e6a7564652f73696d706c652d71756572792d66696c7465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stephenjude/simple-query-filter)[![GitHub Tests Action Status](https://camo.githubusercontent.com/98bafceb7c4f17b4ac27e6aa2cf8b1fe8f92d954586e5c09f43c73ac7fcbe51c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7374657068656e6a7564652f73696d706c652d71756572792d66696c7465722f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/stephenjude/simple-query-filter/actions?query=workflow%3ATests+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/dde5c7b11f683ea238162c37c3cd8cbabe61d95ccc9a7497b4778c5e9ac721c9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7374657068656e6a7564652f73696d706c652d71756572792d66696c7465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stephenjude/simple-query-filter)

This package allows you to filter eloquent model queries based on HTTP request.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require stephenjude/simple-query-filter
```

Usage
-----

[](#usage)

### Add the `WithQueryFilter` trait to your searchable model:

[](#add-the-withqueryfilter-trait-to-your-searchable-model)

```
use Stephenjude\SimpleQueryFilter\WithQueryFilter;

class Post extends Model
{
    use WithQueryFilter;
}
```

### Filter a model based on a request: /posts?column\_name=search\_string:

[](#filter-a-model-based-on-a-request-postscolumn_namesearch_string)

The `filter()` method is used to filter the rows in a table. The result will only include rows that meets all the criteria of the query parameters.

```
class PostController extends Controller
{
    public function index(Request $request)
    {
        // GET /posts?title=simple&slug=simple-query-filter
        $posts = Post::filter($request->query())->latest()->paginate();
    }
}
```

### Search a model based on a request: /posts?column\_name=search\_string:

[](#search-a-model-based-on-a-request-postscolumn_namesearch_string)

The `scout()` method is used to perform a full search on the model. The result for this method includes any row that meets the search criteria.

```
class PostController extends Controller
{
    public function index(Request $request)
    {
        // GET /posts?title=simple&slug=simple-query-filter
        $posts = Post::scout($request->query())->latest()->paginate();
    }
}
```

### Custom Query Parameters

[](#custom-query-parameters)

You can alternatively pass an array of column names and search strings as a key-value pair to the filter method:

```
    $queryParams = [
        'title' => 'Simple',
        'description' => 'Query Filter'
    ];

    $posts = Post::filter($queryParam)->latest()->paginate();
    $posts = Post::scout($queryParam)->latest()->paginate();
```

Column Not Found Exception
--------------------------

[](#column-not-found-exception)

The eloquent filter scope provided in this package will throw a bad request HTTP exception if it fails to find any of the specified column names.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Stephen Jude](https://github.com/StephenJude)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 96.3% 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.

###  Release Activity

Cadence

Every ~222 days

Total

3

Last Release

1581d ago

Major Versions

1.0.1 → 2.0.02022-03-04

PHP version history (2 changes)1.0.0PHP ^7.2|^8.0

2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb8b712638a0d72afbc4e21574989fdfc33717a69ea3070e92104183db8068f9?d=identicon)[stephenjude](/maintainers/stephenjude)

---

Top Contributors

[![stephenjude](https://avatars.githubusercontent.com/u/31182887?v=4)](https://github.com/stephenjude "stephenjude (26 commits)")[![nhedger](https://avatars.githubusercontent.com/u/649677?v=4)](https://github.com/nhedger "nhedger (1 commits)")

---

Tags

stephenjudesimple-query-filter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/stephenjude-simple-query-filter/health.svg)

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)

PHPackages © 2026

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