PHPackages                             craftcodery/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. [Database &amp; ORM](/categories/database)
4. /
5. craftcodery/laravel-searchable

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

craftcodery/laravel-searchable
==============================

Searchable trait for Laravel Eloquent models

3.4.0(8mo ago)06.1k↓16.1%1MITPHPPHP ^8.2

Since Apr 28Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/craftcodery/laravel-searchable)[ Packagist](https://packagist.org/packages/craftcodery/laravel-searchable)[ Docs](https://github.com/craftcodery/laravel-searchable)[ RSS](/packages/craftcodery-laravel-searchable/feed)WikiDiscussions master Synced 1mo ago

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

Laravel Searchable
==================

[](#laravel-searchable)

This package makes it easy to search your Laravel models.

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

[](#installation)

You can install the package via composer:

```
composer require craftcodery/laravel-searchable
```

Usage
-----

[](#usage)

### Preparing your models

[](#preparing-your-models)

In order to search through models you'll have to use the `Searchable` trait and add the `toSearchableArray` method.

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use CraftCodery\Searchable\Searchable;

class User extends Model
{
    use Searchable;

    /**
     * Get the searchable data array for the model.
     *
     * @return array
     */
    public function toSearchableArray()
    {
        return [
            'columns' => [
                'users.name'  => 60,
                'users.email' => 60,
                'locations.city' => 40,
                'organizations.name' => 40
            ],
            'joins'   => [
                'locations' => [
                    'users.location_id',
                    'locations.id'
                ],
                'organizations' => [
                    // use commas to join on multiple columns, e.g. where
                    // organizations.id equals primary_org_id OR secondary_or_id
                    'users.primary_org_id,users.secondary_org_id',
                    'organizations.id'
                ]
            ],
            'groupBy' => 'users.id'
        ];
    }
}
```

### Searching models

[](#searching-models)

To search your models, just use the `search` method.

```
$users = User::search('john')->get();
```

### Configuring search matchers

[](#configuring-search-matchers)

You can configure the different search matchers and weights given to each used by the package.

```
php artisan vendor:publish --tag=searchable-config

```

License
-------

[](#license)

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

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance61

Regular maintenance activity

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 85.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 ~177 days

Recently: every ~231 days

Total

10

Last Release

245d ago

Major Versions

1.0.1 → 2.02022-02-08

2.2.0 → 3.0.02023-03-07

PHP version history (4 changes)1.0PHP ^7.2|^8.0

2.0PHP ^8.0

3.0.0PHP ^8.1

3.4.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3ab2a3ee8b51b91f030e53380e1038a5e12bd7b00cc0c61d4ae5e1732497d910?d=identicon)[aaronhuisinga](/maintainers/aaronhuisinga)

---

Top Contributors

[![aaronhuisinga](https://avatars.githubusercontent.com/u/2423844?v=4)](https://github.com/aaronhuisinga "aaronhuisinga (12 commits)")[![cmorbitzer](https://avatars.githubusercontent.com/u/5883755?v=4)](https://github.com/cmorbitzer "cmorbitzer (1 commits)")[![danfair](https://avatars.githubusercontent.com/u/4053286?v=4)](https://github.com/danfair "danfair (1 commits)")

---

Tags

searchlaraveleloquent

### Embed Badge

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

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17649.9k](/packages/lacodix-laravel-model-filter)[mozex/laravel-scout-bulk-actions

A Laravel Scout extension for bulk importing and flushing of all models.

1033.4k](/packages/mozex-laravel-scout-bulk-actions)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2928.9k7](/packages/stayallive-laravel-eloquent-observable)

PHPackages © 2026

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