PHPackages                             webard/nova-eloquent-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. webard/nova-eloquent-searchable

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

webard/nova-eloquent-searchable
===============================

1.0.0(1y ago)12.7kMITPHP

Since Jul 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/webard/nova-eloquent-searchable)[ Packagist](https://packagist.org/packages/webard/nova-eloquent-searchable)[ RSS](/packages/webard-nova-eloquent-searchable/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Nova Eloquent Searchable
========================

[](#nova-eloquent-searchable)

This simple package comes with two solutions:

1. Make ability to search Eloquent models by Laravel Nova way, using their search configuration
2. Introduce additional search classes with optional value validating

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

[](#installation)

```
composer require webard/nova-eloquent-searchable
```

Search Eloquent models like Nova resources
------------------------------------------

[](#search-eloquent-models-like-nova-resources)

1. Move `public static $search` or `public static searchableColumns()` definition from Nova Resource to Model.
2. Add trait to your Nova Resource

```
use Webard\NovaEloquentSearchable\Trait\NovaEloquentSearch;

class User extends Resource
{
    use NovaEloquentSearch;
}
```

3. Add trait to your model:

```
use Webard\NovaEloquentSearchable\Trait\EloquentSearchable;

class User extends Authenticatable
{
    use EloquentSearchable;
}
```

Now, you can search your models and return values the same way like in Laravel Nova panel:

```
$user = User::searchInDatabase('test@example.com')->first();

dump($user->name);
```

To not conflict with Laravel Scout, scope was called `searchInDatabase`, but if you want use other name, e.g. `search`, just rename Trait method:

```
class User extends Authenticatable
{
    use EloquentSearchable {
        scopeSearchInDatabase as scopeSearch;
    }
}
```

Now, you can search by `search` method:

```
$user = User::search('test@example.com')->first();

dump($user->name);
```

Additional search classes
-------------------------

[](#additional-search-classes)

Laravel Nova comes with some [Searchable Columns Classes](https://nova.laravel.com/docs/search/), but they can search only via MySQL's LIKE or full-text search.

Full-text search is powerful, but "like" searches on large datasets are very inefficient and they cannot use indexes, so this package derives several additional classes along with value validation functionality to optimize searches.

### `EqualValue`

[](#equalvalue)

```
use Webard\NovaEloquentSearchable\Query\Search\EqualValue;

public static function searchableColumns(): array
{
    return [
        'name',
        (new EqualValue('email'))
    ];
}
```

`EqualValue` is used to search for full values. This is a simple comparison in MySQL `WHERE column="value"`. This search method is useful, for example, for searching by e-mail address or telephone number.

Additionally, you can add value validation, so that if the passed value does not meet the condition, it will not be added to the search query.

```
use Webard\NovaEloquentSearchable\Query\Search\EqualValue;

public static function searchableColumns(): array
    {
        return [
            'name',
            (new EqualValue('email'))
                ->validate(fn($value) => Validator::make(
                    [
                        'value' => $value
                    ],
                    [
                        'value' => 'email'
                    ]
                )
                ->passes()
            ),
        ];
    }
```

### `EqualRelation`

[](#equalrelation)

`EqualRelation` class do the same thing as `EqualValue`, but basing on relation instead of column.

Example:

```
use Webard\NovaEloquentSearchable\Query\Search\EqualValue;

public static function searchableColumns(): array
    {
        return [
            'name',
            (new EqualRelation('additionalEmails', 'email'))
                ->validate(fn($value) => Validator::make(
                    [
                        'value' => $value
                    ],
                    [
                        'value' => 'email'
                    ]
                )
                ->passes()
            ),
        ];
    }
```

### `FullTextValue`

[](#fulltextvalue)

`FullTextValue` do the same thing as `SearchableText` class from Laravel Nova, but additionally adds double quote (") characters to search value. So if you search for `John Doe`, to SQL query there is sent `"John Doe"` value. This way, searching in full-text mode is more precise.

Of course value validation like in `EqualValue` is present too.

### `FullTextRelation`

[](#fulltextrelation)

As above, but works with relations instead of columns.

Of course value validation like in `EqualValue` is present too.

TODO
----

[](#todo)

I'm are actively seeking contributions to enhance this package. Here are some features I would love to see implemented:

- tests
- add `validate` method to Laravel Nova searchable classes
- more searchable classes?

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

[](#contributing)

We welcome contributions to improve this plugin! Please follow these steps to contribute:

1. Fork the repository.
2. Create a new branch for your feature or bug fix.
3. Make your changes and commit them with descriptive messages.
4. Push your changes to your forked repository.
5. Open a pull request to the main repository.

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for more details.

Contact
-------

[](#contact)

For questions or support, please open an issue on GitHub.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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

Unknown

Total

1

Last Release

702d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/855788?v=4)[Bartłomiej Gajda](/maintainers/webard)[@webard](https://github.com/webard)

---

Top Contributors

[![webard](https://avatars.githubusercontent.com/u/855788?v=4)](https://github.com/webard "webard (2 commits)")

---

Tags

eloquentlaravellaravel-novanovasearch

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/webard-nova-eloquent-searchable/health.svg)

```
[![Health](https://phpackages.com/badges/webard-nova-eloquent-searchable/health.svg)](https://phpackages.com/packages/webard-nova-eloquent-searchable)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.1M11.1k](/packages/illuminate-database)[kreait/laravel-firebase

A Laravel package for the Firebase PHP Admin SDK

1.3k18.0M46](/packages/kreait-laravel-firebase)[bavix/laravel-wallet

It's easy to work with a virtual wallet.

1.3k1.2M18](/packages/bavix-laravel-wallet)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

438834.4k1](/packages/clickbar-laravel-magellan)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

213389.8k2](/packages/wnx-laravel-backup-restore)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M16](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

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