承接 thejawker/super-random 相关项目开发

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

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

thejawker/super-random

Composer 安装命令:

composer require thejawker/super-random

包简介

Allows for easy unique code generation, is database aware for Laravel Applications.

README 文档

README

Latest Version on Packagist Build Status Quality Score Total Downloads

Nice and fluent way to create truly unique codes or tokens.

Installation

Require the package from Composer:

composer require thejawker/super-random

As of Laravel 5.5 it will magically register the package.

Usage

Just simple call the generate method on SuperRandom Facade or the handy shortcut helper function.

$code = SuperRandom::generate();
echo $code; // 

$code = superRandom();

Examples:

Database Aware

Often you don't want more than one of the same codes or tokens to be present in your database. Although it's easy to compare to the database it is annoying having to re-implement this all over the place. By specifying the table.column in the for method you can easily make it entry aware.

ConcertTicket::create([
    'band' => 'DYSSEBIA',
    'code' => SuperRandom::for(ConcertTicket::class)->generate()
]);

// Or more explicit:
ConcertTicket::create([
    'band' => 'DYSSEBIA',
    'code' => SuperRandom::for('concerts.code')->generate()
]);

Length

You can specify the length as follows:

ConcertTicket::create([
    'band' => 'DYSSEBIA',
    'code' => SuperRandom::length(12)->generate()
]);

Allowed Chars

You can specify the allowed chars as follows:

ConcertTicket::create([
    'band' => 'DYSSEBIA',
    'code' => SuperRandom::chars('abc123')->generate()
]);

By default we only include numbers and UPPERCASE characters with the exclusion of: 1, I, O, 0 since they look a lot alike and you don't want your users to guess.

Full Config

You can alternatively set the config right on the generate() method.

ConcertTicket::create([
    'band' => 'DYSSEBIA',
    'code' => SuperRandom::generate([
        'table' => 'concerts',
        'column' => 'code',
        'length' => 15,
        'chars' => 'abc123'
    ])
]);

Test

composer test

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固