Package Data | |
---|---|
Maintainer Username: | excellentingenuity |
Maintainer Contact: | james.johnson@excellentingenuity.com (James Johnson) |
Package Create Date: | 2016-02-26 |
Package Last Update: | 2022-12-08 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-17 03:01:04 |
Package Statistics | |
---|---|
Total Downloads: | 1,190 |
Monthly Downloads: | 20 |
Daily Downloads: | 0 |
Total Stars: | 59 |
Total Watchers: | 3 |
Total Forks: | 0 |
Total Open Issues: | 0 |
A Package for easily adding UUID's to Eloquent Models supporting Laravel 5.5+
To use UUID in an Eloquent Model install the package with:
composer require eig/eloquent-uuid
Then in your Model instead of extending Model
extend EloquentUUID
like so:
<?php
namespace App;
use eig\EloquentUUID\EloquentUUID;
class UUIDModel extends EloquentUUID
{
}
Then in your migrations make sure you set id to string or uuid like this:
public function up()
{
Schema::create('client_models', function (Blueprint $table) {
$table->uuid('id');
$table->softDeletes();
$table->timestamps();
});
}
For Laravel 5.3+, the standard user model that comes with the framework extends Authenticatble
for the new
multi-auth system. To add in UUID's to the user model extend eig\EloquentUUID\UUIDUser
which will add in the UUID
to the user while still extending Laravel's Authenticatable
class. The migration schema changes for extending
EloquentUUID
are the same for extending from UUIDUser
.
As of version 1.1.0, EloquentUUID now has a trait named UUID
in the namespace eig\EloquentUUID\Traits\UUID
,
that you can use to compose a UUID class. The trait implements a UUID assignment in a __constructor()
method.
The migration schema changes for extending EloquentUUID
are the same for using the UUID
trait.