kduma / eloquent-uuidable
Eloquent Uuidable Trait
v3.0.0
2026-04-08 14:39 UTC
Requires
- php: ^8.3
- illuminate/database: ^13.0
- illuminate/support: ^13.0
This package is auto-updated.
Last update: 2026-04-08 14:42:10 UTC
README
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.