human018/smart-name

此包的最新版本(1.0.1)没有提供许可证信息。

一个模型特性,可以快速直观地将全名转换为单独的姓名、姓氏和其他姓名部分。

安装: 12

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

公开问题: 0

类型:项目

1.0.1 2021-01-18 21:59 UTC

This package is auto-updated.

Last update: 2024-09-19 06:01:53 UTC


README

一个模型特性,可以快速直观地将全名转换为单独的姓名、姓氏和其他姓名部分。

先决条件

此特性使用Laravel框架,并需要Laravel 5及以上版本。

它还要求您的模型表具有名为'first_name'、'last_name'和'title'的列,以便处理姓名。

安装

将包添加到您的composer文件中。

composer require Human018/laravel-smart-name

将特性添加到您希望应用的任何模型中。

use Human018\SmartName\Traits\SmartNameTrait;

class User {
    use SmartNameTrait;
}

这为您模型引入了一个名为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";

如果检测到值为电子邮件地址,此特性还会处理电子邮件地址。

$user->name = "john@mail.com"

// Will perform the following:

$user->first_name = "john";

作者

  • Simon Woodard - 初始工作 - 网站

许可证

本项目采用GNU许可证,详情请参阅LICENSE.md文件。