adamlien/pkuuids is a Laravel package for using a uuid as primarykey for laravel 5.3+.
It currently has 0 GitHub stars and 76 downloads on Packagist (latest version v1.6).
Install it with composer require adamlien/pkuuids.
Discover more Laravel packages by adamlien
or browse all Laravel packages to compare alternatives.
Last updated
PkUuids package use ramsey/uuid[https://github.com/ramsey/uuid] (official installed on 5.3+) to generate a UUID_v4(random) as primary key for Eloquent Model.
inspired by http://stackoverflow.com/questions/31817067/laravel-5-using-a-uuid-as-primary-key
composer require racklin/pkuuids:dev-masterUse a UUID as primary key, we need to change $table->increments('id'); to $table->uuid('id')->primary();
Add $incrementing = false; to your Models.
Add use PkUuuids; to your Models.
Example:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Racklin\PkUuids\PkUuids;
class User extends Model
{
use PkUuids;
public $incrementing = false;
}
Current package version works for Laravel 5.3+ 6.x 7.x 8.x 9.x 10.x