A Laravel package for ULID (Universally Unique Lexicographically Sortable Identifier).
- Make repository on Github
- Make repository on Travis
- Make repository on Coveralls
- Make repository on Packagist
- Write logic classes
- Write test scripts
- Write README & documents
- php >=7.1.3
- Laravel 5.5+
Begin by pulling in the package through Composer.
$ composer require oanhnn/laravel-ulid
To let a model make use of ULIDs, you must add a ulid field as the primary field in the table.
Schema::create('table_name', function (Blueprint $table) {
$table->ulid('id');
$table->primary('id');
// other fields
});
To get your model to work with the encoded ULID (i.e. to use ulid as a primary key), you must let your model use the Laravel\Ulid\HasUlid
trait.
use Illuminate\Database\Eloquent\Model;
use Laravel\Ulid\HasUlid;
class TestModel extends Model
{
use HasUlid;
// other logic codes
}
The UUID of a model will automatically be generated upon save.
$model = MyModel::create();
dump($model->getKey());
See all change logs in CHANGELOG
$ git clone git@github.com/oanhnn/laravel-ulid.git /path
$ cd /path
$ composer install
$ composer test
Please see CONTRIBUTING for details.
If you discover any security related issues, please email to Oanh Nguyen instead of using the issue tracker.
This project is released under the MIT License.
Copyright © Oanh Nguyen.