Uuid primary key for Laravel Eloquent Models
marquine/eloquent-uuid is a Laravel package for uuid primary key for laravel eloquent models.
It currently has 7 GitHub stars and 11.463 downloads on Packagist (latest version v1.2.0).
Install it with composer require marquine/eloquent-uuid.
Discover more Laravel packages by marquine
or browse all Laravel packages to compare alternatives.
Last updated
Uuid primary key for Laravel Eloquent Models.
Install through Composer
composer require marquine/eloquent-uuid
In your migration, create a column for the uuid primary key:
$table->uuid('id')->primary();
or
$table->string('id', 32)->primary();
If your primary key column name is not id, you need to set the model's $primaryKey property to the correct name.
Use the Uuid trait in your model:
<?php
namespace App;
use Marquine\EloquentUuid\Uuid;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use Uuid;
}
Eloquent UUID is licensed under the MIT license.