human018 / smart-name
A Model Trait that quickly & intuitively change names from a full name into separate first, last and other name parts.
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
This package is auto-updated.
Last update: 2025-02-19 07:09:00 UTC
README
A Model Trait that quickly & intuitively change names from a full name into separate first, last and other name parts.
Prerequisites
This Trait uses the Laravel framework and requires Laravel 5 and above.
It also requires that your model table has columns named 'first_name', 'last_name' and 'title' in order to process the name.
Installing
Add the package to your composer file.
composer require Human018/laravel-smart-name
Add the trait to any Model you wish to apply it to.
use Human018\SmartName\Traits\SmartNameTrait; class User { use SmartNameTrait; }
This introduces a new attribute method to your model called name.
$user->name = "Mr John Doe"; // Will perform the following: $user->title = "Mr"; $user->first_name = "John"; $user->last_name = "Doe"; $user->name; // returns "Mr John Doe";
This trait also processes email addresses if it detects the value to be an email address.
$user->name = "john@mail.com" // Will perform the following: $user->first_name = "john";
Authors
- Simon Woodard - Initial work - Website
License
This project is licensed under the GNU License - see the LICENSE.md file for details