PHPackages                             oooiik/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. oooiik/laravel-query-filter

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

oooiik/laravel-query-filter
===========================

In Laravel, it is convenient to write the query filter related to the model in a separate class

1.2.1(1y ago)01.0k↓16.7%2[4 issues](https://github.com/oooiik/laravel-query-filter/issues)MITPHPPHP ^7.3|^8.0

Since Oct 27Pushed 1y ago1 watchersCompare

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

READMEChangelog (7)DependenciesVersions (9)Used By (0)

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

[](#laravel-query-filter)

In Laravel, it is convenient to write the query filter related to the model in a separate class!

### Installation

[](#installation)

```
composer require oooiik/laravel-query-filter

```

### Usage:

[](#usage)

for single use

```
User::filter($validated)->get();
```

or create a filter

```
$userFilter = User::createFilter(UserFilter::class);
```

get a query using a filter

```
$userFilter->apply($validated)->query();
```

write filter on filter and get a query

```
$userFilter->apply($validated);
$userFilter->apply($validated_2)->query();
```

In order to use a filter you have to create a new one by the command that is provided by the package:

```
php artisan make:filter UserFilter

```

This command will create a directory `Filters` and `UserFilter` class inside. To use the filter method of `User` model use the `Filterable` trait:

```
