yearul / unique-id-generator
yearul/unique-id-generator 是一个 Laravel 扩展包,简化了具有自定义格式、长度和规则的唯一 ID 的生成,从而提高了 Laravel 应用程序中生成唯一标识符的效率。
v1.0
2023-05-10 12:01 UTC
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
这里应放置您的描述。请限制为一段或两段。考虑添加一个小示例。
安装
您可以通过 composer 安装此包
composer require yearul/lara-unique-id
您可以使用以下命令发布和运行迁移
php artisan vendor:publish --tag="lara-unique-id-migrations"
php artisan migrate
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="lara-unique-id-config"
这是已发布配置文件的内容
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 ];
可选地,您可以使用以下命令发布视图
php artisan vendor:publish --tag="lara-unique-id-views"
用法
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)
测试
composer test
变更日志
有关最近更改的更多信息,请参阅 变更日志
贡献
有关详细信息,请参阅 贡献指南
安全漏洞
请参阅 我们的安全策略 了解如何报告安全漏洞。
鸣谢
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件