PHPackages                             arielsand/mongodb-eloquent-api-filter-mapping - 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. arielsand/mongodb-eloquent-api-filter-mapping

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

arielsand/mongodb-eloquent-api-filter-mapping
=============================================

Awesome and simple way to filter Monolog/Eloquent queries right from the API call url

v1.1.5(5y ago)02.1kGPL-3.0PHPPHP &gt;=7.2

Since Apr 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/arielsand/mongodb-eloquent-api-filter-mapping)[ Packagist](https://packagist.org/packages/arielsand/mongodb-eloquent-api-filter-mapping)[ RSS](/packages/arielsand-mongodb-eloquent-api-filter-mapping/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (8)Used By (0)

eloquent-api-filter
===================

[](#eloquent-api-filter)

Awesome and simple way to filter Monolog/Eloquent queries right from the API call url

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

[](#installation)

```
composer require arielsand/mongodb-eloquent-api-filter-mapping

```

#### Usage Example

[](#usage-example)

**Using the Trait**

```
class UserController extends Controller
{

    use Arielsand\MoloquentApiFilter\Traits\FiltersMoloquentApi;

    public function index(Request $request)
    {
        $users = User::query();

        return $this->filterApiRequest($request, $users);
    }
}

```

**Using the Class**

```
use Arielsand\MoloquentApiFilter\MoloquentApiFilter;

class UserController extends Controller
{
    public function index(Request $request)
    {
        $query = User::query();

        $filtered = (new MoloquentApiFilter($request, $query))->filter(['value' => 'address'], true);

        return $filtered->get();
    }
}

```

Documentation
=============

[](#documentation)

### New in v1.1

[](#new-in-v11)

##### Chain multiple queries by and/or:

[](#chain-multiple-queries-by-andor)

```
.../model?filter[field]=like:*val1:and:like:val2*:or:null

```

will result in:

```
SELECT * FROM models
WHERE (
            field LIKE '%val1'
        AND field LIKE 'val2%'
      )
      OR field IS NULL

```

##### Added Trait

[](#added-trait)

You can now use Matthenning\\EloquentApiFilter\\Traits\\FiltersEloquentApi to simply filter your requests with

```
$this->filterApiRequest($request, $query);

```

### URL Syntax

[](#url-syntax)

`.../model?filter[field]=operator:comparison`

`.../model?filter[field]=operator`

### Operators:

[](#operators)

like, notlike, today (for timestamps), nottoday (for timestamps), null, notnull, ge (greater or equal), gt (greater), le (lower or equal), lt (lower), eq (equal)

### Example queries

[](#example-queries)

Matches all entities where name starts with Rob and deceased is null:

`.../users?filter[name]=like:Rob*&filter[deceased]=null:`

Multiple filters on one field can be chained. Matches all entities where created\_at is between 2016-12-10 and 2016-12-08:

`.../users?filter[created_at]=lt:2016-12-10:and:gt:2016-12-08`

Filter by related models' fields by using the dot-notaion. Matches all Posts of Users where Post name contains "API"

`.../users?filter[posts.name]=like:*API*`

Filter timestamps. Matches all users whos' birthdays are today

`.../users?filter[birthday]=today`

Limit and sorting. Matches the top 10 users with age of 21 or older sorted by name in ascending order

`.../users?filter[age]=ge:21&order[name]=asc&limit=10`

### Known issues

[](#known-issues)

- Sorting by related fields doesn't work yet.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 53.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 ~212 days

Recently: every ~310 days

Total

7

Last Release

2050d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.6.4

v1.1.4PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/59d8d3cfeee23e3d3f8a716445604d16bdd249304be6c07ac0b4a3b6de02b80d?d=identicon)[arielsand](/maintainers/arielsand)

---

Top Contributors

[![arielsand](https://avatars.githubusercontent.com/u/8807522?v=4)](https://github.com/arielsand "arielsand (16 commits)")[![rustyricky](https://avatars.githubusercontent.com/u/5699183?v=4)](https://github.com/rustyricky "rustyricky (14 commits)")

---

Tags

apieloquentmongodbfiltering

### Embed Badge

![Health badge](/badges/arielsand-mongodb-eloquent-api-filter-mapping/health.svg)

```
[![Health](https://phpackages.com/badges/arielsand-mongodb-eloquent-api-filter-mapping/health.svg)](https://phpackages.com/packages/arielsand-mongodb-eloquent-api-filter-mapping)
```

###  Alternatives

[matthenning/eloquent-api-filter

Awesome and simple way to filter Eloquent queries right from the API URL without the clutter.

104.9k](/packages/matthenning-eloquent-api-filter)

PHPackages © 2026

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