PHPackages                             mohamedgaber-intake40/filter-quent - 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. mohamedgaber-intake40/filter-quent

ActiveLibrary

mohamedgaber-intake40/filter-quent
==================================

An easy way to filter Queries Laravel Eloquent.

v2.0.2(3y ago)61.4k↓100%MITPHP

Since Jun 13Pushed 3y ago2 watchersCompare

[ Source](https://github.com/mohamedgaber-intake40/filter-quent)[ Packagist](https://packagist.org/packages/mohamedgaber-intake40/filter-quent)[ Docs](https://github.com/mohamedgaber-intake40/filter-quent)[ RSS](/packages/mohamedgaber-intake40-filter-quent/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (10)Used By (0)

Laravel Eloquent Filter
=======================

[](#laravel-eloquent-filter)

An easy way to filter Queries Laravel Eloquent.

Install (Laravel)
=================

[](#install-laravel)

```
$ composer require mohamedgaber-intake40/filter-quent

```

The Package is auto discovered , but you can register Service Provider in config/app.php

```
 'providers' => [
    \Filter\Providers\FilterServiceProvider::class
];
```

Usage
=====

[](#usage)

\##Filter

- make filter class using this command for example UserFilter

```
php artisan make:filter UserFilter

```

- this will generate UserFilter in app\\Filters

---

- add the Filter\\Traits\\HasFilter trait to your model(s):

```
  class User extends Authenticatable
  {
        use HasFilter;
  }
```

- this will add filter scope to User model
- note : User model its filter class should be UserFilter by default , but you can override this by overriding getFilterClassName method in the model

```
protected function getFilterClassName()
{
    return App\Filters\MyUserFilter::class;
}
```

---

- in App\\Filters\\UserFilter Class , you have to add methods to filter model properties for example :
    - if you want to filter name you have to add filter name method like this

```
protected function filterName($name)
{
    $this->query->where('name','like',"%$name%");
}
```

- also, you can filter any relations , example : user has many posts

```
  protected function filterPosts($posts)
  {
      $this->query->whereHas('posts',function($q) use ($posts){
        $q->whereIn('id',$posts);
      });
  }
```

---

- now you can filter your model query like this

```
 App\Models\User::filter([ 'name' => 'test' , 'posts' => [1,2,3] ])->get();
```

Notes
-----

[](#notes)

- filter method must be filter{property} example to filter name , it will be filterName
- if property is something\_something , method will be filterSomethingSomething , example : filterFirstName
- when filter class has many methods like filterName, filterAge these methods will be called only when filter array has property matched with the method name

---

\##Sort

- add the Filter\\Traits\\HasSortable trait to your model(s):

```
  class User extends Authenticatable
  {
      use HasSortable;
  }
```

- add sortable array to your model(s):

```
/**
* The attributes that can be sorted.
*
* @var array
*/
protected $sortable = [
  'id',
  'name',
  'created_at',
  'updated_at'
];
```

this array to define which attributes that are available for sorting

- now you can sort your model query like this

```
 App\Models\User::sortable()->get();
```

and the request should have query string like this :

- /users?sort\[\]=id,desc
- /users?sort\[\]=id,asc
- /users?sort\[\]=id,asc&amp;sort\[\]=name,asc (multiple sorting)

Notes
-----

[](#notes-1)

- if query string has additional attribute that doesn't exist in the sortable array , will be ignored

---

\##Select

- add the Filter\\Traits\\HasSelectable trait to your model(s):

```
  class User extends Authenticatable
  {
      use HasSelectable;
  }
```

- add selectable array to your model(s):

```
/**
* The attributes that can be sorted.
*
* @var array
*/
protected $selectable = [
  'id',
  'name',
  'created_at',
  'updated_at'
];
```

this array to define which attributes that are available for selecting

- now you can select your model query like this

```
 App\Models\User::selectable()->get();
```

and the request should have query string like this :

- /users?select=id,name

Notes
-----

[](#notes-2)

- if query string has additional attribute that doesn't exist in the selectable array , will be ignored
- if query string doesn't have select , all attributes will be returned

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.5% 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 ~88 days

Recently: every ~124 days

Total

7

Last Release

1262d ago

Major Versions

v1.x-dev → v2.02021-12-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/295c7926de41e4d03cd783419fdce54a79b8ae89d239b6912ea4721ef4e6e504?d=identicon)[mohamedgaber-intake40](/maintainers/mohamedgaber-intake40)

---

Top Contributors

[![mohamedgaber-intake40](https://avatars.githubusercontent.com/u/53451971?v=4)](https://github.com/mohamedgaber-intake40 "mohamedgaber-intake40 (17 commits)")[![mgaber2024](https://avatars.githubusercontent.com/u/154437100?v=4)](https://github.com/mgaber2024 "mgaber2024 (1 commits)")[![osama-eltayar](https://avatars.githubusercontent.com/u/19836844?v=4)](https://github.com/osama-eltayar "osama-eltayar (1 commits)")

### Embed Badge

![Health badge](/badges/mohamedgaber-intake40-filter-quent/health.svg)

```
[![Health](https://phpackages.com/badges/mohamedgaber-intake40-filter-quent/health.svg)](https://phpackages.com/packages/mohamedgaber-intake40-filter-quent)
```

PHPackages © 2026

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