juniorb2ss/eloquent-uuid
Eloquent UUID Trait
The juniorb2ss/eloquent-uuid provider a simple trait to implement UUID to ORM.
Install
You can install this package via composer:
$ composer require juniorb2ss/eloquent-uuid~1.*
Eloquent Trait
use juniorb2ss\EloquentUuid\EloquentUuidTrait;
class User extends Authenticatable
{
use Notifiable, EloquentUuidTrait;
/**
* UUID Column name used
*
* @var string
* @optional
*/
protected $uuidKey = 'uuid';
}
UUID Column
You need create new column in table model like uuid or custom name you can define in uuidKey model property
Example
$fields = $request->only(['email', 'name', 'password']);
$user = User::create($fields); // Creating user with auto-inject uuid field
dump($user->toArray());
/*[
"id" => "1"
"uuid" => "723e4628-7c35-11e7-89b1-0242bfc0df57",
"name" => "Magdalena Zboncak"
"email" => "nitzsche.katherine@gulgowski.com"
]*/
Scope On UUID
use App\User;
$user = (new User)->onUuid('aae5f3f1-0f22-4a8b-9291-d2a9649d1490')
->firstOrFail();
Tests
composer run test
Change log
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
Related Packages
doctrine/dbal
Powerful PHP database abstraction layer (DBAL) with many features for database s...
634,760,849
9,707
laravel/serializable-closure
Laravel Serializable Closure provides an easy and secure way to serialize closur...
408,553,772
609
nunomaduro/collision
Cli error handling for console/command-line PHP applications.
387,976,821
4,658

