kaantanis/coderator

简单独特的代码生成器,可选配置

v1.0.3 2023-09-16 17:22 UTC

This package is auto-updated.

Last update: 2024-09-29 19:26:59 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

此包提供了一个简单独特的代码生成器,带有可选配置。

安装

您可以通过 composer 安装此包

composer require kaantanis/coderator

您可以使用以下命令发布配置文件

php artisan vendor:publish --tag="coderator-config"

这是已发布配置文件的内容

return [
    'default_length' => 6,
];

用法

$coderator = new \KaanTanis\Coderator\Coderator();

$my_code = $coderator->model(\App\Models\Product:class)
    ->field('code') // required. For create unique code
    ->prefix('#PR') // optional. default is empty
    ->length(6) // optional. except prefix, default is 6
    ->generate(); // returns a unique code
// $my_code = '#PRAY81QH'

// Without optional configurations
$my_code = $coderator->model(\App\Models\Product:class)
    ->field('code') // required. For create unique code
    ->generate(); // returns a unique code    
// $my_code = '8EYQHG'

// Now you can use it this unique code for your model. E.g. Product model
Product::create([
    'code' => $my_code, // absolute unique code 8EYQHG
    ...
]);

变更日志

有关最近更改的更多信息,请参阅 变更日志

路线图

  • 后缀选项
  • 可能创建的代码将存储在具有模型和字段名称的数据库表中。因此,生成唯一代码将更快。
  • 更多测试
  • 更多配置
  • 更多咖啡

贡献

有关详细信息,请参阅 贡献指南

安全漏洞

请查看 我们的安全策略 了解如何报告安全漏洞。

鸣谢

许可协议

MIT 许可协议 (MIT)。有关更多信息,请参阅 许可文件