yearul / unique-id-generator
yearul/unique-id-generator is a Laravel package that simplifies the generation of unique IDs with customizable formats, lengths, and rules, enhancing the efficiency of generating unique identifiers in Laravel applications.
Requires
- php: >=7.4|^8.0
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
README
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
Installation
You can install the package via composer:
composer require yearul/lara-unique-id
You can publish and run the migrations with:
php artisan vendor:publish --tag="lara-unique-id-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="lara-unique-id-config"
This is the contents of the published config file:
return [ /* |-------------------------------------------------------------------------- | Unique Id Generator Config |-------------------------------------------------------------------------- | | This is the config file for unique id generator. You can override | this config file by placing it in your application's config directory | and change the values as per your need. | */ /* |-------------------------------------------------------------------------- | Default Pad Length |-------------------------------------------------------------------------- | | If no pad length is provided to the generate method, this value will be used | */ "pad_len" => 5, /* |-------------------------------------------------------------------------- | Default Prefix |-------------------------------------------------------------------------- | | If no prefix is provided to the generate method, this value will be used | */ "prefix" => "YEA", /* |-------------------------------------------------------------------------- | Default year and year_val |-------------------------------------------------------------------------- | | If no year and year_val is provided to the generate method, this value will be used | */ "year" => true, "year_val" => date('Y'), /* |-------------------------------------------------------------------------- | Default pad string |-------------------------------------------------------------------------- | | If no pad string is provided to the generate method, this value will be used | */ "pad_string" => '0', // 0, #, *, $.......etc /* |-------------------------------------------------------------------------- | Default pad_direction |-------------------------------------------------------------------------- | | If no pad_direction is provided to the generate method, this value will be used | */ "pad_direction" => STR_PAD_LEFT, // STR_PAD_LEFT, STR_PAD_RIGHT ];
Optionally, you can publish the views using
php artisan vendor:publish --tag="lara-unique-id-views"
Usage
use Yearul\LaraUniqueId\LaraUniqueId; // import this in the top of the class $value = LaraUniqueId::generate(2); echo $value; // generate($input, $pad_len = null, $pad_string = null, $prefix = null, $year = null) // the generate method received 5 value, $input value is mandatory and others value not mandatory( thoes can get from config file)
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.