PHPackages                             heseya/laravel-searchable - 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. heseya/laravel-searchable

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

heseya/laravel-searchable
=========================

Search trait for Eloquent models

2.0.0(4y ago)24.1kMITPHPPHP &gt;=7.3

Since Aug 14Pushed 4y ago4 watchersCompare

[ Source](https://github.com/heseya/laravel-searchable)[ Packagist](https://packagist.org/packages/heseya/laravel-searchable)[ RSS](/packages/heseya-laravel-searchable/feed)WikiDiscussions master Synced yesterday

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

Heseya\\Searchable
==================

[](#heseyasearchable)

[![Made by Heseya](https://camo.githubusercontent.com/1237c877f44449513736825a83167d8e0f6ec36eeb82e1fbc5d8d08a563ed32e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d61646525323062792d4865736579612d3639303031663f7374796c653d666c61742d737175617265)](https://heseya.com)[![StyleCI](https://camo.githubusercontent.com/213b638374d72d710d21148a28513adf90a3eb270dfd77f45d2af658c3086416/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3238363232373536312f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/286227561)[![Packagist Version](https://camo.githubusercontent.com/7b17c58bf4e6b1199d2068e8cdfc00af1a0401a57592950c68592007d7fc010f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6865736579612f6c61726176656c2d73656172636861626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/heseya/laravel-searchable)[![Total Downloads](https://camo.githubusercontent.com/5affa996a356670c2aead5ff490279510eeb4c8e6b1c452571974ea023561a05/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6865736579612f6c61726176656c2d73656172636861626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/heseya/laravel-searchable)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

🔍 Search trait for Eloquent models.

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

[](#installation)

```
$ composer require heseya/laravel-searchables

```

How to use it?
--------------

[](#how-to-use-it)

```
class User extends Model
{
    use HasCriteria;

    protected $criteria = [
        'id', // default criterion
        'email' => Equals::class,
        'name' => Like::class,
        'description' => Custom::class,
    ];
}
```

```
class Controller
{
    function index(Request $request)
    {
        User::searchByCriteria([
            'email' => 'example@example.com',
            'name' => 'John'
        ])->get();

        // you can extend query

        User::searchByCriteria($request->all())
            ->where('public', true)
            ->get();
    }
}
```

Available criteria
------------------

[](#available-criteria)

- Equals
- Like

Custom criterion
----------------

[](#custom-criterion)

```
final class CustomCriterion extends Criterion
{
    public function query(Builder $query): Builder
    {
        // do whatever you want

        return $query;
    }
}
```

Change default criterion in model
---------------------------------

[](#change-default-criterion-in-model)

```
class User extends Model
{
    protected function getDefaultCriterion(): string
    {
        return Equals::class;
    }
}
```

Testing
-------

[](#testing)

To run the tests, run the following command from the project folder.

```
$ composer test

```

License
-------

[](#license)

Package released under the MIT License. See the [LICENSE](https://github.com/heseya/laravel-searchable/blob/master/LICENSE) file for details.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~577 days

Total

2

Last Release

1520d ago

Major Versions

1.0.0 → 2.0.02022-03-14

### Community

Maintainers

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

---

Top Contributors

[![bvlinsky](https://avatars.githubusercontent.com/u/38615612?v=4)](https://github.com/bvlinsky "bvlinsky (2 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

heseyalaravellibraryphpsearch

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/heseya-laravel-searchable/health.svg)

```
[![Health](https://phpackages.com/badges/heseya-laravel-searchable/health.svg)](https://phpackages.com/packages/heseya-laravel-searchable)
```

###  Alternatives

[algolia/scout-extended

Scout Extended extends Laravel Scout adding algolia-specific features

4186.3M6](/packages/algolia-scout-extended)[swisnl/laravel-fulltext

Fulltext indexing and searching for Laravel

184104.5k6](/packages/swisnl-laravel-fulltext)[kyslik/laravel-filterable

Using URL query strings to filter Eloquent queries.

11539.0k](/packages/kyslik-laravel-filterable)[devnoiseconsulting/laravel-scout-postgres-tsvector

PostgreSQL Full Text Search Driver for Laravel Scout

58110.1k](/packages/devnoiseconsulting-laravel-scout-postgres-tsvector)[vanry/laravel-scout-tntsearch

包含中文分词的 Laravel Scout TNTSearch 驱动，支持 scws, phpanalysis 和 jieba 分词。

17811.8k1](/packages/vanry-laravel-scout-tntsearch)[gtk/larasearch

A driver based solution to searching your Eloquent models supports Laravel 5.2 and Elasticsearch engine.

133.9k](/packages/gtk-larasearch)

PHPackages © 2026

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