yaroslawww / laravel-eloquent-user-fullname
Simple helper, to quickly add user fields: First Name, Middle Name, Last Name, username, Name, Full Name
0.3.0
2019-07-07 12:32 UTC
Requires
- php: ^7.2
Requires (Dev)
- larapack/dd: ^1.0
- phpunit/phpunit: ^8.2
This package is auto-updated.
Last update: 2024-12-08 01:22:35 UTC
README
Simple helper, to quickly add user "name" fields: First Name
, Middle Name
, Last Name
, Name
, Full Name
.
You can quickly add a library and do not write additional tests as the library covers them. Or you can just copy Trait :)
Installation
You can install the package via composer:
composer require yaroslawww/laravel-eloquent-user-fullname
Usage
use Angecode\LaravelFullName\Models\Traits\HasFullName; ... class User extends Authenticatable { use HasFullName; ... }
$user = User::first(); $user->first_name // Yaroslav $user->middle_name // Dev $user->last_name // Georgitsa $user->name // Yaroslav Georgitsa $user->full_name // Yaroslav Dev Georgitsa
Publish
There added stub migration file to add required fields
php artisan vendor:publish --provider="Angecode\LaravelFullName\FullNameServiceProvider" --tag="migrations"
Helpers
Package provide helper functions
$result = StrHelper::implodeFiltered([ 'foo', null, 'bar', '' ]); echo $result; // "foo bar" $result = StrHelper::implodeFiltered([ 'foo', 'test', 'bar', 'test', ], '|', function ($item){ return $item == 'test'; }); echo $result; // "test|test"
Testing
composer test
Security
If you discover any security related issues, please email yaroslav.georgitsa@gmail.com instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.