human018/smart-name

There is no license information available for the latest version (1.0.1) of this package.

A Model Trait that quickly & intuitively change names from a full name into separate first, last and other name parts.

1.0.1 2021-01-18 21:59 UTC

This package is auto-updated.

Last update: 2024-04-19 05:10:53 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