Looking to hire Laravel developers? Try LaraJobs

laravel-uuid maintained by healthengine

Description
Use UUIDs as primary keys for Eloquent models
Last update
2023/05/24 04:07 (dev-master)
License
Links
Downloads
26 400
Tags

Comments
comments powered by Disqus

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.