tsubasarcs/laravel-recommendation
Composer 安装命令:
composer require tsubasarcs/laravel-recommendation
包简介
cp member get member database package
README 文档
README
This package provides to generate user unique code with Laravel.
Installation
Currently this package only for laravel 5.5.
Install via composer
$ composer require tsubasarcs/laravel-recommendation
Publish Migration and Config
Run the following to publish the migrations on your terminal:
$ php artisan vendor:publish --provider="Tsubasarcs\Recommendations\RecommendationServiceProvider" --tag="migrations"
If you want to change some parameters, you can run the following to publish the config on your terminal:
$ php artisan vendor:publish --provider="Tsubasarcs\Recommendations\RecommendationServiceProvider" --tag="config"
Setting
Model Recommendation
If you want to do customize model and column, please check Recommendation Model "code" column to prevent code duplicate.
// config/recommendation.php ... 'model' => [ 'name' => \Tsubasarcs\Recommendations\Recommendation::class, 'code_column' => 'code', ],
Model Recommendation is default belongs to \Tsubasarcs\Recommendations\IlluminateUser::class,
You need to change it to your application model.
// config/recommendation.php ... 'relation_model' => \Tsubasarcs\Recommendations\IlluminateUser::class,
Default attributes
Generating Code type and length attributes can be customize via setting default key value.
// config/recommendation.php ... 'default' => [ 'type' => 1, 'length' => 10, ],
Code structure has three parts, prefix, timestamp and code.
You can decide to join prefix and timestamp or not and custom symbol between part and part.
// config/recommendation.php ... // Default only code. 'code_structure' => [ 'prefix' => '', 'timestamp' => false, 'symbol' => '-' ]
Usage
Generating Code
Code Facade end point is generate(), it will return an array.
Code::generate(); // [['type' => 1,'code' => 'X6nbxJ8DHk']];
If you are not using endpoint, it will return CodeService instance.
Code::type(2); // Tsubasarcs\Recommendations\CodeService {#result: [], #times: 1, #type: 2, #length: 10};
#Example
Code::prefix('cp') ->timestamp(true) ->symbol('@') ->type(2) ->length(15) ->times(2) ->generate(); // [ // ["type" => 2, "code" => "cp@1557454693@4PZHxJXdM7K8OBo"], // ["type" => 2, "code" => "cp@1557454693@rnExFAeD18GDMhs"] // ]; 'X6nbxJ8DHk' // default 'cp-X6nbxJ8DHk' // config('recommendation.code_structure.prefix') == 'cp' '1557287118-Gnr3olcOD6' // config('recommendation.code_structure.timestamp') == true 'cp_1557287118_X6nbxJ8DHk' // config('recommendation.code_structure.prefix') == 'cp' // config('recommendation.code_structure.timestamp') == true // config('recommendation.code_structure.symbol') == '_'
tsubasarcs/laravel-recommendation 适用场景与选型建议
tsubasarcs/laravel-recommendation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 49 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 04 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 tsubasarcs/laravel-recommendation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tsubasarcs/laravel-recommendation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 49
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-29