定制 ajaydev/pin-generator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ajaydev/pin-generator

Composer 安装命令:

composer require ajaydev/pin-generator

包简介

README 文档

README

This composer package is for Laravel to create a unique identifier, In this instance, a PIN (personal identification number), suitable for use with door locks, etc. Each time the code executes, it return at least one PIN, that has adhered to the following:

• The initial intention is that each PIN comprises of four numeric digits (e.g. “2845”),
• This package will not generate “obvious” numbers. This can be handled

programmatically to account for the following restrictions, but allow for additional to be added later

-> Palindromes
    • Invalid examples include : 2332,5555 etc.

-> Sequential numbers
    • Invalid examples Include : 0123,1234,1235etc.

-> Repeating numbers
    • Invalid examples Include : 1115,7377 etc.

-> As an example, 4942 would be a PIN that passes these 3 restrictions.
    • This package will provide the PINs in an apparently random order.
    • This package will not repeat a PIN until all the preceding valid PINs have been utilised - even if the solution is stopped and started between PINs being returned.
    • You can specify the lenght of the pin e.g. 4, 6, 7, 12-digit pins. But the recommendation will be to not use a very big number. 

Table of Contents

Support

Supported PHP versions are from ^7.2.5 till ^8.2
Supported Laravel versions are from 8+

Installation

Run the following command at the root directory of your project to install the the pin-generator package:

composer require ajaydev/pin-generator dev-main

And after succesfully downloading this package add service provider to your

<project_root>/config/app.php

in this array of providers

'providers' => [
    // add this line in your providers array
    AjayDev\PinGenerator\PinGeneratorServiceProvider::class,
],

this line

AjayDev\PinGenerator\PinGeneratorServiceProvider::class,

Usage

After completion the above mentioned steps you just need to use this facade in your controller

use AjayDev\PinGenerator\PinGeneratorFacade;

and after this simply

$pin = PinGeneratorFacade::generatePin(2);  #at the place of two you can pass your length as per your requirement by default it will be 4 if you remove 2

UnitTestCases ( Optional )

If you want you can run and see all the test cases working perfectly or not with this command in you root project directory.

php artisan test vendor/ajaydev/pin-generator/tests/PinGeneratorTest.php

That's it you are are good to go.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固