This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Create non-incrementing Laravel models whose primary key is a UUID

0.1.0 2015-10-22 01:41 UTC

This package is auto-updated.

Last update: 2021-10-14 04:42:54 UTC


Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

Create non-incrementing models whose primary key is a UUID.


Via Composer

$ composer require stevenmaguire/laravel-uuid-model


Extend the UuidModel

class User extends Stevenmaguire\Laravel\UuidModel

By default any model that extends the UuidModel will automatically assign a random UUID value to the primaryKey while creating.

To include custom "UUID attributes", each model that extends the UuidModel can declare those attributes as an array value for the uuidAttributes property.

class User extends Stevenmaguire\Laravel\UuidModel
     * Auto-assigned uuid model attributes.
     * @var array
    public $uuidAttributes = ['foo', 'bar'];

This will result in the model's primary key, id, foo, and bar all being automatically assigned a random UUID value.


$ ./vendor/bin/phpunit


Please see CONTRIBUTING for details.


If you discover any security related issues, please email instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.