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

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

fynduck/laravel-searchable
==========================

A description for laravel-searchable.

2.2(5y ago)0662MITPHPPHP &gt;=7.0

Since Feb 8Pushed 5y ago1 watchersCompare

[ Source](https://github.com/fynduck/laravel-searchable)[ Packagist](https://packagist.org/packages/fynduck/laravel-searchable)[ RSS](/packages/fynduck-laravel-searchable/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (8)Dependencies (1)Versions (9)Used By (0)

laravel-searchable
==================

[](#laravel-searchable)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Latest Version on Packagist](https://camo.githubusercontent.com/d0968b47a4277e16d4eb6267c165b1ac0352e5b070e5f7707b200df899ac7a87/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66796e6475636b2f6c61726176656c2d73656172636861626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fynduck/laravel-searchable)[![Total Downloads](https://camo.githubusercontent.com/868e75e33e48d01daf80750942ac53c370afd224b31dfbc4f35691f6231acc24/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66796e6475636b2f6c61726176656c2d73656172636861626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fynduck/laravel-searchable)

Install
-------

[](#install)

`composer require fynduck/laravel-searchable`

Usage
-----

[](#usage)

```
use Fynduck\LaravelSearchable\src\Searchable;

class User extends \Eloquent
{
    use Searchable;

     /**
     * Searchable rules.
     * Columns and their priority in search results.
     * Columns with higher values are more important.
     * Columns with equal values have equal importance.
     * @var array
     * @return array
     */
    protected function toSearchableArray()
    {
        return [
            'columns' => [
                'name'  => 10,
                'email' => 5,
            ],
             'joins' => [
                 'posts' => ['users.id','posts.user_id'],
             ],
        ];
    }

    /**
     * Select fields
     * @return array
     */
    public function selectFields()
    {
        return [
            'users.name',
            'users.email'
        ];
    }

    public function posts()
    {
        return $this->hasMany('Post');
    }

}
```

Now you can search your model.

```
// Simple search
$users = User::search($query)->get();

// Search and get relations
// It will not get the relations if you don't do this
$users = User::search($query)
            ->with('posts')
            ->get();
```

Search Paginated
----------------

[](#search-paginated)

As easy as laravel default queries

```
// Search with relations and paginate
$users = User::search($query)
            ->with('posts')
            ->paginate(20);
```

Mix queries
-----------

[](#mix-queries)

Search method is compatible with any eloquent method. You can do things like this:

```
// Search only active users
$users = User::where('status', 'active')
            ->search($query)
            ->paginate(20);
```

Custom Threshold
----------------

[](#custom-threshold)

The default threshold for accepted relevance is the sum of all attribute relevance divided by 4. To change this value you can pass in a second parameter to search() like so:

```
// Search with lower relevance threshold
$users = User::where('status', 'active')
            ->search($query, 0)
            ->paginate(20);
```

The above, will return all users in order of relevance.

Entire Text search
------------------

[](#entire-text-search)

By default, multi-word search terms are split and Searchable searches for each word individually. Relevance plays a role in prioritizing matches that matched on multiple words. If you want to prioritize matches that include the multi-word search (thus, without splitting into words) you can enable full text search by setting the third value to true. Example:

```
// Prioritize matches containing "John Doe" above matches containing only "John" or "Doe".
$users = User::search("John Doe", null, true)->get();
```

If you explicitly want to search for full text matches only, you can disable multi-word splitting by setting the fourth parameter to true.

```
// Do not include matches that only matched "John" OR "Doe".
$users = User::search("John Doe", null, true, true)->get();
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security-related issues, please email DummyAuthorEmail instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](/LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~95 days

Recently: every ~78 days

Total

8

Last Release

1982d ago

Major Versions

1.3 → 2.02020-04-04

### Community

Maintainers

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

---

Top Contributors

[![fynduck](https://avatars.githubusercontent.com/u/12099534?v=4)](https://github.com/fynduck "fynduck (12 commits)")

---

Tags

laravel

### Embed Badge

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

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

###  Alternatives

[tapp/filament-value-range-filter

Filament country code field.

2362.2k](/packages/tapp-filament-value-range-filter)[webbingbrasil/filament-datefilter

Date filter component for filament tables.

1479.4k](/packages/webbingbrasil-filament-datefilter)[mobileka/scope-applicator

Scope Applicator is a PHP trait that makes data filtering and sorting easy.

251.2k2](/packages/mobileka-scope-applicator)[remoblaser/search

A simple to implement Search for your Application

101.5k](/packages/remoblaser-search)

PHPackages © 2026

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