Skip to content
This repository has been archived by the owner on May 24, 2023. It is now read-only.

Use UUIDs as primary keys for Eloquent models

License

Notifications You must be signed in to change notification settings

HealthengineAU/laravel-uuid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.