Laravel package to generate unique identifiers
Installs: 1 921
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^7.1
- hashids/hashids: 3.0
- laravel/framework: >=5.5
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-11-05 01:30:57 UTC
README
Laravel package to create automatic unique nullable identifiers like u5CVsCnxyXg
for your Eloquent models.
Installation
Require this package
composer require continuum-digital/uid
Usage
Configuration
Create a new entry in database.config.php
to configure your uid's:
'uid' => [
'salt' => '', // Default ''
'minLength' => '', // Default 0
'alphabet' => '', // Default 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
],
You can remove the salt
, minLength
or alphabet
to use default values.
Database
Add the $table->uid()
in your Schemas:
Schema::create('your_table', function (Blueprint $table) {
$table->uid();
})
Eloquent
Add the HasUid
trait to your Models
to add the capabilities:
- Local scope
$model->uid($uid)
- Automatic generation of
uid
during thecreating
event
Notes
This package use HashIds under the hood.