finagin/laravel-extra-support
Composer 安装命令:
composer require finagin/laravel-extra-support
包简介
Extra Support methods for Laravel
README 文档
README
Installation
composer require finagin/laravel-extra-support
Usage
Str::randomWithExclude()
Returns random string with excludes.
use Illuminate\Support\Str; Str::randomWithExclude(); Str::randomWithExclude(15); Str::randomWithExclude(16, ['a', 'b', 'c']); Str::randomWithExclude(16, 'abc');
Str::randomAlpha()
Returns random string without numeric.
use Illuminate\Support\Str; Str::randomAlpha(); Str::randomAlpha(15);
Customization
<?php namespace App\Services; use Finagin\ExtraSupport\Services\MacrosRegistrar; use Illuminate\Support\Str; class CustomMacrosRegistrar extends MacrosRegistrar { /** * @return \Illuminate\Support\Collection|array */ public function additionalRegisters() { return [ '\\Illuminate\\Support\\Str@randomExcludeSimilar' => 'registerMacroRandomExcludeSimilar', ]; } protected function registerMacroRandomExcludeSimilar() { Str::macro('randomExcludeSimilar', static function ($length = 16) { return Str::randomWithExclude($length, ['1', 'l', '0', 'O']); }); } }
In config replace registrar with new registrar class:
<?php return [ 'registrar' => \App\Services\CustomMacrosRegistrar::class, // ... ];
Finally, add dependencies to the appropriate section if you need them:
<?php return [ // ... 'dependencies' => [ // ... '\\Illuminate\\Support\\Str@randomExcludeSimilar' => [ '\\Illuminate\\Support\\Str@randomWithExclude', ], // ... ], // ... ];
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-07-15