helmab/model-unique-code

为Laravel模型生成唯一代码

v1.0.0 2022-04-30 07:13 UTC

This package is auto-updated.

Last update: 2024-09-29 05:57:09 UTC


README

Latest Version on Packagist Total Downloads

为Laravel模型生成唯一代码。示例 INV-96752304

安装

您可以通过composer安装此包

composer require helmab/model-unique-code

使用方法

<?php

namespace App\Models;

use Helmab\ModelUniqueCode\Traits\HasModelUniqueCode;
use Illuminate\Database\Eloquent\Model;

class Invoice extends Model
{
    use HasModelUniqueCode;
    
    protected $key_unique_code = 'code'; // default
    
    protected $length_unique_code = 8; // default
    
    protected $prefix_unique_code = "INV"; // random
    
    protected $type_unique_code = "number"; // number, string, mixed
    
    protected $has_prefix_unique_code = false; // default

    protected $fillable = [
        'code',
    ];
}

测试

composer test

变更日志

请参阅变更日志以获取有关最近更改的更多信息。

贡献

请参阅贡献指南以获取详细信息。

安全性

如果您发现任何安全相关的问题,请通过电子邮件mabhelitc@gmail.com联系,而不是使用问题跟踪器。

致谢

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。