cosmicvibes/laraseries 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

cosmicvibes/laraseries

Composer 安装命令:

composer require cosmicvibes/laraseries

包简介

Number series package for Laravel

README 文档

README

Latest Stable Version Latest Unstable Version Total Downloads License StyleCI Build Status

Laraseries: Laravel Number Series Package

I had a business requirement to create an incrementing part number for products, that cannot be reused. E.g: first item: IN00001, next item IN00002 etc.

This package simplifies the creation of multiple number series and allows you to easily retrieve the next available number, saving the incremented value to the number series. It uses database transactions to ensure the next number is always atomic.

Requirements

  • PHP 7.1.3+
  • Laravel 5.8+

Will likely work on other versions, but is untested.

Installation

  1. Install the package by running this command in your terminal/cmd:
composer require cosmicvibes/laraseries dev-master

Usage

Implements Laravel Eloquent models. A demo application with tests can be found at: https://github.com/cosmicvibes/laraseries-demo

First create a number series:

$numberSeries = new Cosmicvibes\Laraseries\NumberSeries();

$numberSeries->fill([
            'code'              => 'TEST',
            'name'              => 'Test Number Series',
            'prefix'            => 'TEST',
            'suffix'            => 'Y',
            'length'            => 10,
            'increment_by'      => 1,
            'padding_character' => 0, // Can be anything
            'start_date'        => Carbon::createFromFormat('d/m/Y', '01/01/2001'), // Can be left blank, implement checks in your own code
            'end_date'          => null, // Can be left blank, implement checks in your own code
            'active'            => true, // For your reference, implement checks in your own code
            'starting_number'   => 1, // Defaults to 0
            'ending_number'     => null, // Defaults to max possible number based on length        
]);

$numberSeries->save();

Or find an existing model (any eloquent commands will work, see the Laravel documentation for more details):

$numberSeries = NumberSeries::whereCode('TEST')->get()->first();

Retrieve the current number:

echo $numberSeries->current;
TEST0000000001Y

Advance to the next number (the function will return the new current number):

$currentNumber = $numberSeries->advance():
TEST0000000002Y

Advance by a set amount:

$currentNumber = $numberSeries->advance(15):
TEST00000000017Y

Note that if you advance past the ending number then advancing further will return null. It is recommended that you implement checking for this situation.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Special Thanks to

cosmicvibes/laraseries 适用场景与选型建议

cosmicvibes/laraseries 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 458 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 05 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 cosmicvibes/laraseries 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cosmicvibes/laraseries 我们能提供哪些服务?
定制开发 / 二次开发

基于 cosmicvibes/laraseries 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-10