Download the PHP package ignition-nbs/laravel-uuid-model without Composer
On this page you can find all versions of the php package ignition-nbs/laravel-uuid-model. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ignition-nbs/laravel-uuid-model
More information about ignition-nbs/laravel-uuid-model
Files in ignition-nbs/laravel-uuid-model
Package laravel-uuid-model
Short Description Enable Laravel's Eloquent Model to be identified by UUID (string) rather than ID (increment or bigIncrement)
License MIT
Informations about the package laravel-uuid-model
Laravel UUID Model
laravel-uuid-model provides 1 PHP Trait that implements the initialization
function and is thus called by the Illuminate\Database\Eloquent\Model
constructor. The initializeUuidModel
sets $incrementing
to FALSE, $keyType
to"string"
, and it will ensure that the id
attribute can be mass-assigned.
Then it generates a version 4 universally unique identifier for the id
attribute and sets that value already in $this->attributes['id']
.
It is important to note that this Trait works better then UUID Model classes
that extend Laravel's Model
class: Classes that have intermediate parent
classes (e.g. App\User
) will not work with those type of UUID Model classes.
This package works with Laravel 5.7, 5.8, 6.x and 7.x.
Installation
If you do install and use this package, please send a postcard to
Usage
There are two things that you must do in order to make successful use of this
UuidModel
:
-
Use
IgnitionNbs\LaravelUuidModel\UuidModel
inside your model class: - Set the
id
field in the corresponding migration by using theuuid()
function:
Changelog
Please see CHANGELOG for information on what has changed recently.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
MIT