Skip to content

kduma-OSS/LV-eloquent-ulidable

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Eloquent ULID-able

Latest Stable Version Total Downloads License

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 numeric id as the primary key and stores the ULID in a separate column.

About

Eases using and generating ulid's in Laravel Eloquent models.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 100.0%