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
- PHP
^8.3 - Laravel
^13.0
composer require kduma/eloquent-ulidableuse 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.