oanhnn / laravel-ulid
A Laravel package for ULID (Universally Unique Lexicographically Sortable Identifier)
Requires
- php: ^7.1.3
- illuminate/database: ^5.5
- illuminate/support: ^5.5
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/database: ^3.5
- orchestra/testbench: ^3.5
- phpunit/phpunit: ^6.3|^7.0
- squizlabs/php_codesniffer: ^3.2
This package is auto-updated.
Last update: 2024-11-21 21:19:39 UTC
README
A Laravel package for ULID (Universally Unique Lexicographically Sortable Identifier).
TODO
- 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
Requirements
- php >=7.1.3
- Laravel 5.5+
Installation
Begin by pulling in the package through Composer.
$ composer require oanhnn/laravel-ulid
Usage
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 }
Creating a model
The UUID of a model will automatically be generated upon save.
$model = MyModel::create(); dump($model->getKey());
Changelog
See all change logs in CHANGELOG
Testing
$ git clone git@github.com/oanhnn/laravel-ulid.git /path $ cd /path $ composer install $ composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email to Oanh Nguyen instead of using the issue tracker.
Credits
License
This project is released under the MIT License.
Copyright © Oanh Nguyen.