Looking to hire Laravel developers? Try LaraJobs

laravel-eloquent-user-fullname maintained by yaroslawww

Description
Simple helper, to quickly add user fields: First Name, Middle Name, Last Name, username, Name, Full Name
Last update
2019/07/07 14:32 (dev-master)
License
Downloads
4

Comments
comments powered by Disqus

Quickly add user "name" fields

Software License Build Status StyleCI Quality Score Code Coverage PHP Version Packagist Version

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.