kduma/eloquent-uuidable
Eloquent UUID-able
Eloquent trait that adds a UUID as an additional column alongside the numeric id in Laravel models.
Full documentation: opensource.duma.sh/libraries/php/eloquent-uuidable
Requirements
- PHP
^8.3 - Laravel
^13.0
Installation
composer require kduma/eloquent-uuidable
Usage
use KDuma\Eloquent\Uuidable;
use KDuma\Eloquent\Attributes\HasUuid;
#[HasUuid(field: 'uuid')]
class User extends Model
{
use Uuidable;
}
Add a uuid column to your migration:
$table->uuid('uuid')->unique();
UUID is auto-generated on create. Find by UUID with User::whereUuid($uuid) or User::byUuid($uuid).
Unlike Laravel's built-in
HasUuids, this package keeps the numericidas the primary key and stores the UUID in a separate column.
Related Packages
gstjohn/eloquent-uuids
Easily allow Laravel Eloquent models to utilize UUIDs as their primary key.
6
0
imcity-tech/laravel-uuid
[fork] The package provides UUID keys functionality for Eloquent models with one...
1,684
0
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v3.0.0 | ^8.3 | ^13.0 | MIT | |
| v1.0.1 | >=5.4.0 | MIT | ||
| v1.0 | >=5.4.0 | MIT |