kduma / eloquent-ulidable
Eloquent Ulidable Trait
v3.0.0
2026-04-08 15:04 UTC
Requires
- php: ^8.3
- illuminate/database: ^13.0
- illuminate/support: ^13.0
This package is auto-updated.
Last update: 2026-04-08 15:04:58 UTC
README
Eloquent trait that adds a ULID as an additional column alongside the numeric id in Laravel models.
Full documentation: opensource.duma.sh/libraries/php/eloquent-ulidable
Requirements
- PHP
^8.3 - Laravel
^13.0
Installation
composer require kduma/eloquent-ulidable
Usage
use KDuma\Eloquent\Ulidable; use KDuma\Eloquent\Attributes\HasUlid; #[HasUlid(field: 'ulid')] class Post extends Model { use Ulidable; }
Add a ulid column to your migration:
$table->ulid()->unique();
ULID is auto-generated on create. Find by ULID with Post::whereUlid($ulid) or Post::byUlid($ulid).
Unlike Laravel's built-in
HasUlids, this package keeps the numericidas the primary key and stores the ULID in a separate column.