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

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

hamzaejaz/laravel-searchable-scope
==================================

A Laravel trait to add dynamic search to models

v1.0.2(1y ago)13.4k↑100%[1 issues](https://github.com/iam-hamza/laravel-searchable-scope/issues)MITPHPPHP ^8.0CI failing

Since May 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/iam-hamza/laravel-searchable-scope)[ Packagist](https://packagist.org/packages/hamzaejaz/laravel-searchable-scope)[ RSS](/packages/hamzaejaz-laravel-searchable-scope/feed)WikiDiscussions v1 Synced today

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

Laravel Searchable Scope
========================

[](#laravel-searchable-scope)

A powerful and flexible search trait for Laravel Eloquent models that makes implementing search functionality a breeze.

Features
--------

[](#features)

- Simple and intuitive API
- Configurable search behavior
- Support for related model searching
- Case-sensitive/insensitive search options
- Multiple search operators support
- Minimum search term length configuration
- Default search columns configuration

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

[](#installation)

You can install the package via composer:

```
composer require hamzaejaz/laravel-searchable-scope
```

The package will automatically register its service provider.

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="HamzaEjaz\SearchableScope\SearchableScopeServiceProvider" --tag="config"
```

This will create a `config/searchable-scope.php` file where you can modify the default settings.

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Add the trait to your model:

```
use HamzaEjaz\SearchableScope\Traits\Searchable;

class User extends Model
{
    use Searchable;
}
```

Then you can search like this:

```
// Search in all default columns
User::search('john')->get();

// Search in specific columns
User::search('john', ['name', 'email'])->get();

// Search in related models
User::search('john', [], ['posts' => ['title', 'content']])->get();
```

### Advanced Usage

[](#advanced-usage)

You can define default searchable columns and relations in your model:

```
class User extends Model
{
    use Searchable;

    protected $searchable = [
        'columns' => ['name', 'email', 'username'],
        'relations' => [
            'posts' => ['title', 'content'],
            'profile' => ['bio', 'location']
        ]
    ];
}
```

Now you can simply call:

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

Configuration Options
---------------------

[](#configuration-options)

The package comes with several configuration options in `config/searchable-scope.php`:

- `default_operator`: The default search operator (LIKE, =, &gt;, &lt;, &gt;=, &lt;=)
- `case_sensitive`: Whether the search should be case sensitive
- `default_columns`: Default columns to search if none specified
- `min_term_length`: Minimum length of search term before search is performed

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

[](#contributing)

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

License
-------

[](#license)

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

###  Health Score

28

↓

LowBetter than 52% of packages

Maintenance25

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

4

Last Release

413d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e12aa9d0152932567d6a7f0401b10515f3412b1b6c5e9addb02b45c667ea71ce?d=identicon)[iam-hamza](/maintainers/iam-hamza)

---

Top Contributors

[![iam-hamza](https://avatars.githubusercontent.com/u/79766762?v=4)](https://github.com/iam-hamza "iam-hamza (9 commits)")

---

Tags

laravel-frameworkmodelsearching

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[awesome-nova/dependent-filter

Dependent filters for Laravel Nova

26193.1k](/packages/awesome-nova-dependent-filter)[algolia/laravel-scout-algolia-macros

A collection macros to extend Laravel Scout with more Algolia capabilities

3633.8k](/packages/algolia-laravel-scout-algolia-macros)[algolia/php-dom-parser

A simple tool to turn DOM into Algolia search friendly record objects.

181.8k](/packages/algolia-php-dom-parser)

PHPackages © 2026

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