PHPackages                             plin-code/laravel-full-name - 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. plin-code/laravel-full-name

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

plin-code/laravel-full-name
===========================

Search and sort Eloquent queries and Filament tables by a person's full name across first\_name and last\_name columns, with BelongsTo and HasOne relation support and multi-token matching.

v1.1.0(2mo ago)1141[1 PRs](https://github.com/plin-code/laravel-full-name/pulls)MITPHPPHP ^8.4CI passing

Since Apr 21Pushed 1mo agoCompare

[ Source](https://github.com/plin-code/laravel-full-name)[ Packagist](https://packagist.org/packages/plin-code/laravel-full-name)[ Docs](https://github.com/plin-code/laravel-full-name)[ GitHub Sponsors](https://github.com/PlinCode)[ RSS](/packages/plin-code-laravel-full-name/feed)WikiDiscussions main Synced 3w ago

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

Laravel Fullname
================

[](#laravel-fullname)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a636c8eb686ba972e5ed8c0b8f42f005971f6fc4f58017847c262654d0929ee3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706c696e2d636f64652f6c61726176656c2d66756c6c2d6e616d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/plin-code/laravel-full-name)[![GitHub Tests Action Status](https://camo.githubusercontent.com/2b4e8f5d6acaaba5c3efde060f2b9f7c799176b66842d4d86daba3a7ac69446d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706c696e2d636f64652f6c61726176656c2d66756c6c2d6e616d652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/plin-code/laravel-full-name/actions/workflows/run-tests.yml)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/4171c7c105d2ef10e7de1c59ac620ef3289ff98daffdeaae92b09128aec28aad/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706c696e2d636f64652f6c61726176656c2d66756c6c2d6e616d652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/plin-code/laravel-full-name/actions/workflows/fix-php-code-style-issues.yml)[![PHPStan Action Status](https://camo.githubusercontent.com/c4bfc548bdcc121b316d4d7e53506687644c04ae7cb2735fbf4042654d99cd31/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706c696e2d636f64652f6c61726176656c2d66756c6c2d6e616d652f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e267374796c653d666c61742d737175617265)](https://github.com/plin-code/laravel-full-name/actions/workflows/phpstan.yml)[![Total Downloads](https://camo.githubusercontent.com/391060c3cb9a19ba83e3654056ac7e32264cf382342416172dc718ebe5411ba9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706c696e2d636f64652f6c61726176656c2d66756c6c2d6e616d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/plin-code/laravel-full-name)

Search and sort Eloquent queries (and Filament tables) by a person's full name stored across two columns (`first_name` and `last_name`), either on the main model or on a `BelongsTo` / `HasOne` relation.

What it solves
--------------

[](#what-it-solves)

Filament's built-in `->searchable(['first_name', 'last_name'])` searches each column independently, which fails for composite queries like `"mario rossi"`. The native `->sortable(query: ...)` works for direct columns but requires repetitive custom join logic for relation-based sort. This package encapsulates the solution once, tested once, documented once.

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

[](#installation)

```
composer require plin-code/laravel-full-name
```

No config file, no migrations, no Blade views, no Artisan command. The service provider auto-registers.

Requirements
------------

[](#requirements)

- PHP 8.4
- Laravel 12 or 13
- Filament 4 or 5 (optional, only needed for the Filament layer)
- MySQL 8, PostgreSQL 14+, or SQLite 3

Quick start
-----------

[](#quick-start)

### Standalone Eloquent

[](#standalone-eloquent)

```
Booking::query()
    ->searchFullName($request->input('q'))
    ->orderByFullName('asc')
    ->paginate();

Booking::query()
    ->searchFullName($request->input('q'), relation: 'user')
    ->orderByFullName('asc', relation: 'user')
    ->paginate();
```

### Filament, direct columns

[](#filament-direct-columns)

```
use Filament\Tables\Columns\TextColumn;

TextColumn::make('full_name')
    ->fullNameSearchable()
    ->fullNameSortable();
```

### Filament, via `BelongsTo`

[](#filament-via-belongsto)

```
TextColumn::make('user.full_name')
    ->fullNameSearchable(relation: 'user')
    ->fullNameSortable(relation: 'user');
```

### Filament, via `HasOne`

[](#filament-via-hasone)

```
// User hasOne(Hiker::class) — search and sort users by their hiker full name.
TextColumn::make('hiker.full_name')
    ->fullNameSearchable(relation: 'hiker')
    ->fullNameSortable(relation: 'hiker');
```

### Custom column names

[](#custom-column-names)

```
TextColumn::make('full_name')
    ->fullNameSearchable(
        firstNameColumn: 'given_name',
        lastNameColumn: 'family_name',
    )
    ->fullNameSortable(
        firstNameColumn: 'given_name',
        lastNameColumn: 'family_name',
    );
```

The complete API surface lives in [docs/api.md](docs/api.md).

Performance considerations
--------------------------

[](#performance-considerations)

The matching strategy uses `LOWER(CONCAT(COALESCE(first, ''), ' ', COALESCE(last, '')))` which prevents btree indexes from being used on `first_name` or `last_name`. On tables up to a few hundred thousand rows this is typically acceptable for admin panel search. For very large tables, pair this package with a dedicated search engine (Meilisearch, Scout, Algolia) and use this package only for sort.

Matching behavior
-----------------

[](#matching-behavior)

The core uses `LOWER(CONCAT(COALESCE(first, ''), ' ', COALESCE(last, '')))` matched with `LIKE ? ESCAPE '!'` in both forward and reversed concatenation forms.

QueryRecordMatches`mario`first\_name=`'Mario'`, last\_name=`'Rossi'`yes`rossi`first\_name=`'Mario'`, last\_name=`'Rossi'`yes`mario rossi`first\_name=`'Mario'`, last\_name=`'Rossi'`yes`rossi mario`first\_name=`'Mario'`, last\_name=`'Rossi'`yes`maria`first\_name=`'Marianna'`, last\_name=`'Rossi'`yes (substring, single token)`maria rossi`first\_name=`'Marianna'`, last\_name=`'Rossi'`no (multi token)`marianna rossi`first\_name=`'Marianna'`, last\_name=`'Rossi'`yes`mario giovanni rossi`first\_name=`'Mario Giovanni'`, last\_name=`'Rossi'`yes`rossi mario giovanni`first\_name=`'Mario Giovanni'`, last\_name=`'Rossi'`yes`bianchi mario`first\_name=`'Mario'`, last\_name=`'Rossi Bianchi'`yesThe asymmetry between single token and multi token queries is intentional and emerges from the SQL pattern. Single token queries use substring match, so `maria` matches records containing `maria` anywhere in either column. Multi token queries require the tokens to appear contiguously with the separating space between them in the concatenated `first last` or `last first` form, so `maria rossi` matches `Maria Rossi` but not `Marianna Rossi` (the separator space is not present between `maria` and `rossi` in the concatenation). Single token queries are exploratory (the user may be typing a prefix), multi token queries target a specific person.

See [docs/conventions.md](docs/conventions.md) for the rationale behind the naming split between the Eloquent and Filament layers.

Limitations
-----------

[](#limitations)

1. Only the `BelongsTo` and `HasOne` relation types are supported. `HasMany`, `BelongsToMany`, `MorphTo`, and nested relations raise `UnsupportedRelationException` at query build time.
2. Accent and diacritic normalization is delegated to the database collation. On MySQL, use `utf8mb4_unicode_ci` or `utf8mb4_0900_ai_ci`. On PostgreSQL, consider the `unaccent` extension if needed.
3. Fuzzy matching (soundex, metaphone, Levenshtein, trigram) is out of scope.
4. Single column full name (one `name` column) is not handled. Filament's native `->searchable(['name'])` covers that case already.
5. Empty or whitespace only search input leaves the query unchanged (no `WHERE` clause is added).
6. When combining `orderByFullName(relation: ...)` with an explicit `->select([...])` on the main query, qualify the column names with the main table name (for example `->select(['test_bookings.id'])` rather than `->select(['id'])`). The package performs a `joinSub` under the hood, which can introduce ambiguity for unqualified columns that exist on both tables.

Testing
-------

[](#testing)

```
composer test
composer analyse
composer format
```

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

[](#contributing)

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

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for recent changes.

Credits
-------

[](#credits)

- [Daniele Barbaro](https://github.com/plin-code)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance89

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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

Total

2

Last Release

87d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7653cedfb706bdbaceab17cb57fa55d5e2744faeb722cfc1e2af8c3fd88f13ef?d=identicon)[danielebarbaro](/maintainers/danielebarbaro)

---

Top Contributors

[![danielebarbaro](https://avatars.githubusercontent.com/u/4376886?v=4)](https://github.com/danielebarbaro "danielebarbaro (43 commits)")

---

Tags

eloquentfilamentlaravelname-searchsearchsortsearchlaraveleloquentsortfilamentfull namefilament-tablesname-search

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/plin-code-laravel-full-name/health.svg)

```
[![Health](https://phpackages.com/badges/plin-code-laravel-full-name/health.svg)](https://phpackages.com/packages/plin-code-laravel-full-name)
```

###  Alternatives

[spatie/laravel-medialibrary

Associate files with Eloquent models

6.2k43.2M656](/packages/spatie-laravel-medialibrary)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M98](/packages/mongodb-laravel-mongodb)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.6k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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