PHPackages                             ahoysolutions/query-filters - 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. ahoysolutions/query-filters

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

ahoysolutions/query-filters
===========================

A Laravel package to filter database queries based on the query string.

v1.1.2(8y ago)135MITPHPPHP ~7.0

Since Jul 11Pushed 8y ago1 watchersCompare

[ Source](https://github.com/ahoysolutions/query-filters)[ Packagist](https://packagist.org/packages/ahoysolutions/query-filters)[ RSS](/packages/ahoysolutions-query-filters/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (7)Versions (5)Used By (0)

Query Filters
=============

[](#query-filters)

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

[](#installation)

### Step 1: Composer

[](#step-1-composer)

From the command line, run:

```
composer require ahoysolutions/query-filters

```

### Step 2: Service Provider

[](#step-2-service-provider)

From within your Laravel application, open `config/app.php` and within the `providers` array, add:

```
AhoySolutions\QueryFilters\QueryFilterServiceProvider::class

```

This will bootstrap the package into Laravel for you.

Usage
-----

[](#usage)

### Adding a filters class to a model

[](#adding-a-filters-class-to-a-model)

You can add a filter class through artisan command, just like with controllers, models, or other similar resources. For example, assuming you wanted to leverage filters on your Post model, you might use:

```
php artisan make:queryfilters PostFilters

```

Afterwards, a new query filter class will be added to your `app/Filters/` directory.

### Adding filter methods

[](#adding-filter-methods)

To add a filter method to an filter class, simply add a function to the class. For example, assume you have an incoming request with a query string that looks like `www.example.com/posts?user=johnsmith&popular`.

Your filters class might then look like this:

```
