healthengine/laravel-uuid

This package is abandoned and no longer maintained. The author suggests using the laravel/framework package instead.

Use UUIDs as primary keys for Eloquent models

1.3.0 2020-11-10 04:48 UTC

This package is auto-updated.

Last update: 2023-05-24 02:07:51 UTC


README

Warning

This repository is archived.

Use laravel/framework instead.

Laravel UUID

Latest Stable Version Total Downloads Build Status

This is a custom package designed for Laravel Eloquent. It provides a trait that can be used in model classes that will automatically generate a UUID primary key instead of the default auto-incrementing integer.

Usage

All that is necessary to have this working is to use the trait in the model class. An example is shown below.
Don't forget that the migration will need to be changed to create a UUID (or string) column instead of an integer column. You'll also need to explicitly set the column as the primary key.

use HealthEngine\LaravelUuid\UuidPrimaryKey;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use UuidPrimaryKey;

    //
}

License

Laravel UUID is licensed under the MIT license.