kduma/eloquent-tokenable
最新稳定版本:v1.2.0
Composer 安装命令:
composer require kduma/eloquent-tokenable
包简介
Allows using tokens (HashIDs) instead of id in Laravel Eloquent models.
关键字:
README 文档
README
Allows using tokens (HashIDs) instead of id in Laravel Eloquent models.
Check full documentation here: opensource.duma.sh/libraries/php/eloquent-tokenable
Setup
Add the package to the require section of your composer.json and run composer update
"kduma/eloquent-tokenable": "^1.1"
Prepare models
In your model add following lines:
use \KDuma\Eloquent\Tokenable;
protected $appends = array('token');
Optionally you can add also:
-
protected $salt = 'SALT';
A salt for making hashes. Default is table name. This salt is added to yourAPP_KEY. -
protected $length = 10;
A salt length. Default is 10. -
protected $alphabet = 'qwertyuiopasdfghjklzxcvbnm1234567890';
A hash alphabet. Default isabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
Usage
$model->token- Generate tokensModel::whereToken($id)->first()- Find by token. (whereTokenis query scope)
Hashids
A special thanks to creators of hashids, a PHP class that this package is based.
Packagist
View this package on Packagist.org: kduma/eloquent-tokenable
统计信息
- 总下载量: 176
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-31