Skip to content

kduma-OSS/LV-eloquent-ulidable

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

L5-eloquent-ulidable

Latest Stable Version Total Downloads Latest Unstable Version License

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

Setup

Install it using composer

composer require kduma/eloquent-ulidable

Prepare models

Inside your model (not on top of file) add following lines:

use \KDuma\Eloquent\Ulidable;

In database create ulid string field. If you use migrations, you can use following snippet:

$table->ulid()->unique();

Usage

By default, it generates slug on first save.

  • $model->regenerateUlid() - Generate new ulid. (Remember to save it by yourself)
  • Model::whereUlid($ulid)->first() - Find by ulid. (whereUlid is query scope)

Packagist

View this package on Packagist.org: kduma/eloquent-ulidable

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%