PHPackages                             odoku/eloquent-searcher - 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. odoku/eloquent-searcher

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

odoku/eloquent-searcher
=======================

Give searching power to Eloquent.

1.1(9y ago)115.5kMITPHPPHP &gt;=7.0

Since Feb 24Pushed 9y ago1 watchersCompare

[ Source](https://github.com/odoku/EloquentSearcher)[ Packagist](https://packagist.org/packages/odoku/eloquent-searcher)[ RSS](/packages/odoku-eloquent-searcher/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

Eloquent Searcher
=================

[](#eloquent-searcher)

Usage
-----

[](#usage)

Create searcher class.

```
namespace App\Searchers;

use EloquentSearcher\Searcher;

class UserSearcher extends Searcher
{
    protected $searchFields = [
        'group.name' => Searcher::EQUALS,
        'name' => Searcher::CONTAINS,
        'is_active' => Searcher::IS_TRUE,
        'created_at' => Searcher::DATE_RANGE,
        'project' => 'searchProject',
    ];

    protected $keywordFields = [
        'group.name' => Searcher::EQUALS,
        'name' => Searcher::CONTAINS,
        'notes' => Searcher::CONTAINS,
    ];

    protected function searchProject($query, $field, $value)
    {
        return $query->whereHas('projects', function ($query) use ($value) {
            return $query->where('projects', $value);
        });
    }
}
```

Implement searcher trait into your model.

```
namespace App\Models;

use EloquentSearcher\SearchableTrait;
use Illuminate\Database\Eloquent\Model;

use App\Searchers\UserSearcher;

class User extends Model
{
    use SearchableTrait;

    protected $searcher = UserSearcher::class;
    protected $table = 'users';
    public $timestamps = true;

    protected $fillable = [
        'name',
        'is_active',
        'notes',
    ];

    protected $guarded = [];

    public function group()
    {
        return $this->belongsTo(Group::class);
    }

    public function projects()
    {
        return $this->hasMany(Project::class);
    }
}
```

And use it.

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Models\User;

class UserController extends Controller
{
    public function index(Request $request)
    {
        $conditions = $request->all();
        // $conditions = [
        //     'keyword' => 'programmer',
        //     'group' => [
        //         'name' => 'Employee',
        //     ],
        //     'name' => 'James',
        //     'project' => 'Impressive Project',
        //     'is_active' => true,
        //     'created_at' => [
        //         'from' => '2016-01-01',
        //         'until' => '2016-12-31',
        //     ],
        // ];
        $users = User::search($conditions);
        return view('index', ['users' => $users]);
    }
}
```

Builtin Rules
-------------

[](#builtin-rules)

- Searcher::EQUALS
- Searcher::CONTAINS
- Searcher::STARTSWITH
- Searcher::ENDSWITH
- Searcher::GT
- Searcher::GTE
- Searcher::LT
- Searcher::LTE
- Searcher::RANGE
- Searcher::DATE\_RANGE
- Searcher::DATETIME\_RANGE
- Searcher::IN
- Searcher::IS\_NULL
- Searcher::IS\_NOT\_NULL
- Searcher::IS\_TRUE
- Searcher::IS\_NOT\_TRUE
- Searcher::IS\_FALSE
- Searcher::IS\_NOT\_FALSE

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~4 days

Total

2

Last Release

3359d ago

### Community

Maintainers

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

---

Top Contributors

[![odoku](https://avatars.githubusercontent.com/u/195677?v=4)](https://github.com/odoku "odoku (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/odoku-eloquent-searcher/health.svg)

```
[![Health](https://phpackages.com/badges/odoku-eloquent-searcher/health.svg)](https://phpackages.com/packages/odoku-eloquent-searcher)
```

###  Alternatives

[swisnl/laravel-fulltext

Fulltext indexing and searching for Laravel

184104.5k6](/packages/swisnl-laravel-fulltext)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[baijunyao/laravel-scout-elasticsearch

Elasticsearch Driver for Laravel Scout

8023.7k1](/packages/baijunyao-laravel-scout-elasticsearch)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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