承接 marjose123/laravel-numberizer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

marjose123/laravel-numberizer

最新稳定版本:1.0.2

Composer 安装命令:

composer require marjose123/laravel-numberizer

包简介

Laravel package to create autonumber for Eloquent model

README 文档

README

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

Introduction

Laravel-Numberizer is a fork of laravel-autonumber with a support of latest laravel version.

Installation

You can install the package via composer:

composer require marjose123/laravel-numberizer

You can publish and run the migrations with:

php artisan vendor:publish --tag="numberizer-migrations"
php artisan migrate

You can publish the config file with:

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

This is the contents of the published config file:

return [
 /*
    * '?' will be replaced with the increment number.
    */
    'placeholder' => '?',
    /*
     * The number of digits in the autonumber
     */
    'length' => (int) 6,
    /*
     *   The Starting Value you want to start the creation of the incremental number
     */
    'startingValue' => (int) 11111
];

Usage

  1. Add the AutoNumber contracts and add also to your model the HasNumberizer concerns.
use  \MarJose123\LaravelNumberizer\Contracts\AutoNumber;
use \MarJose123\LaravelNumberizer\Concerns\HasNumberizer;

class Purchase extends Model implements AutoNumber
{
    use HasNumberizer;
    
    /**
     * Return the autonumber configuration array for this model.
     *
     * @return array
     */
    public function getAutoNumberOptions()
    {
        return [
            'purchase_number' => [
                'format' => 'PO-?', // autonumber format. '?' will be replaced with the generated number.
                'length' => 5 // The number of digits in an autonumber
            ]
        ];
    }

}
  1. If you want to use closure on your format you do so.
public function getAutoNumberOptions()
{
    return [
        'purchase_number' => [
            'format' => function () {
                return 'PO-' . \Carbon\Carbon::today()->year . '-?'; // autonumber format. '?' will be replaced with the generated number.
            },
            'length' => 6 // The number of digits in the autonumber
        ]
    ];
}

The purchase_number will be automatically generated based on the format given when saving the Purchase model.

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

Thank you!

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固