{"id":49878131,"url":"https://github.com/plin-code/laravel-full-name","last_synced_at":"2026-05-15T13:11:21.239Z","repository":{"id":354389476,"uuid":"1216799013","full_name":"plin-code/laravel-full-name","owner":"plin-code","description":"Search and sort Eloquent queries and Filament tables by a person's full name across first_name and last_name, with BelongsTo relation support.","archived":false,"fork":false,"pushed_at":"2026-04-28T10:01:03.000Z","size":75,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-28T12:05:23.981Z","etag":null,"topics":["eloquent","filament","laravel","name-search","search","sort"],"latest_commit_sha":null,"homepage":"https://www.plincode.tech/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plin-code.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"PlinCode"}},"created_at":"2026-04-21T08:42:42.000Z","updated_at":"2026-04-28T10:01:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/plin-code/laravel-full-name","commit_stats":null,"previous_names":["plin-code/laravel-full-name"],"tags_count":2,"template":false,"template_full_name":"spatie/package-skeleton-laravel","purl":"pkg:github/plin-code/laravel-full-name","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plin-code%2Flaravel-full-name","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plin-code%2Flaravel-full-name/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plin-code%2Flaravel-full-name/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plin-code%2Flaravel-full-name/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plin-code","download_url":"https://codeload.github.com/plin-code/laravel-full-name/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plin-code%2Flaravel-full-name/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33067640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eloquent","filament","laravel","name-search","search","sort"],"created_at":"2026-05-15T13:11:20.663Z","updated_at":"2026-05-15T13:11:21.232Z","avatar_url":"https://github.com/plin-code.png","language":"PHP","funding_links":["https://github.com/sponsors/PlinCode"],"categories":[],"sub_categories":[],"readme":"# Laravel Fullname\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/plin-code/laravel-full-name.svg?style=flat-square)](https://packagist.org/packages/plin-code/laravel-full-name)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/plin-code/laravel-full-name/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/plin-code/laravel-full-name/actions/workflows/run-tests.yml)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/plin-code/laravel-full-name/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/plin-code/laravel-full-name/actions/workflows/fix-php-code-style-issues.yml)\n[![PHPStan Action Status](https://img.shields.io/github/actions/workflow/status/plin-code/laravel-full-name/phpstan.yml?branch=main\u0026label=phpstan\u0026style=flat-square)](https://github.com/plin-code/laravel-full-name/actions/workflows/phpstan.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/plin-code/laravel-full-name.svg?style=flat-square)](https://packagist.org/packages/plin-code/laravel-full-name)\n\nSearch 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.\n\n## What it solves\n\nFilament's built-in `-\u003esearchable(['first_name', 'last_name'])` searches each column independently, which fails for composite queries like `\"mario rossi\"`. The native `-\u003esortable(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.\n\n## Installation\n\n```bash\ncomposer require plin-code/laravel-full-name\n```\n\nNo config file, no migrations, no Blade views, no Artisan command. The service provider auto-registers.\n\n## Requirements\n\n- PHP 8.4\n- Laravel 12 or 13\n- Filament 4 or 5 (optional, only needed for the Filament layer)\n- MySQL 8, PostgreSQL 14+, or SQLite 3\n\n## Quick start\n\n### Standalone Eloquent\n\n```php\nBooking::query()\n    -\u003esearchFullName($request-\u003einput('q'))\n    -\u003eorderByFullName('asc')\n    -\u003epaginate();\n\nBooking::query()\n    -\u003esearchFullName($request-\u003einput('q'), relation: 'user')\n    -\u003eorderByFullName('asc', relation: 'user')\n    -\u003epaginate();\n```\n\n### Filament, direct columns\n\n```php\nuse Filament\\Tables\\Columns\\TextColumn;\n\nTextColumn::make('full_name')\n    -\u003efullNameSearchable()\n    -\u003efullNameSortable();\n```\n\n### Filament, via `BelongsTo`\n\n```php\nTextColumn::make('user.full_name')\n    -\u003efullNameSearchable(relation: 'user')\n    -\u003efullNameSortable(relation: 'user');\n```\n\n### Filament, via `HasOne`\n\n```php\n// User hasOne(Hiker::class) — search and sort users by their hiker full name.\nTextColumn::make('hiker.full_name')\n    -\u003efullNameSearchable(relation: 'hiker')\n    -\u003efullNameSortable(relation: 'hiker');\n```\n\n### Custom column names\n\n```php\nTextColumn::make('full_name')\n    -\u003efullNameSearchable(\n        firstNameColumn: 'given_name',\n        lastNameColumn: 'family_name',\n    )\n    -\u003efullNameSortable(\n        firstNameColumn: 'given_name',\n        lastNameColumn: 'family_name',\n    );\n```\n\nThe complete API surface lives in [docs/api.md](docs/api.md).\n\n## Performance considerations\n\nThe 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.\n\n## Matching behavior\n\nThe core uses `LOWER(CONCAT(COALESCE(first, ''), ' ', COALESCE(last, '')))` matched with `LIKE ? ESCAPE '!'` in both forward and reversed concatenation forms.\n\n| Query | Record | Matches |\n|---|---|---|\n| `mario` | first_name=`'Mario'`, last_name=`'Rossi'` | yes |\n| `rossi` | first_name=`'Mario'`, last_name=`'Rossi'` | yes |\n| `mario rossi` | first_name=`'Mario'`, last_name=`'Rossi'` | yes |\n| `rossi mario` | first_name=`'Mario'`, last_name=`'Rossi'` | yes |\n| `maria` | first_name=`'Marianna'`, last_name=`'Rossi'` | yes (substring, single token) |\n| `maria rossi` | first_name=`'Marianna'`, last_name=`'Rossi'` | no (multi token) |\n| `marianna rossi` | first_name=`'Marianna'`, last_name=`'Rossi'` | yes |\n| `mario giovanni rossi` | first_name=`'Mario Giovanni'`, last_name=`'Rossi'` | yes |\n| `rossi mario giovanni` | first_name=`'Mario Giovanni'`, last_name=`'Rossi'` | yes |\n| `bianchi mario` | first_name=`'Mario'`, last_name=`'Rossi Bianchi'` | yes |\n\nThe 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.\n\nSee [docs/conventions.md](docs/conventions.md) for the rationale behind the naming split between the Eloquent and Filament layers.\n\n## Limitations\n\n1. Only the `BelongsTo` and `HasOne` relation types are supported. `HasMany`, `BelongsToMany`, `MorphTo`, and nested relations raise `UnsupportedRelationException` at query build time.\n2. 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.\n3. Fuzzy matching (soundex, metaphone, Levenshtein, trigram) is out of scope.\n4. Single column full name (one `name` column) is not handled. Filament's native `-\u003esearchable(['name'])` covers that case already.\n5. Empty or whitespace only search input leaves the query unchanged (no `WHERE` clause is added).\n6. When combining `orderByFullName(relation: ...)` with an explicit `-\u003eselect([...])` on the main query, qualify the column names with the main table name (for example `-\u003eselect(['test_bookings.id'])` rather than `-\u003eselect(['id'])`). The package performs a `joinSub` under the hood, which can introduce ambiguity for unqualified columns that exist on both tables.\n\n## Testing\n\n```bash\ncomposer test\ncomposer analyse\ncomposer format\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for recent changes.\n\n## Credits\n\n- [Daniele Barbaro](https://github.com/plin-code)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplin-code%2Flaravel-full-name","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplin-code%2Flaravel-full-name","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplin-code%2Flaravel-full-name/lists"}