infinety-es / token
1.1
2016-05-02 15:37 UTC
Requires
- php: >=5.5.9
- illuminate/support: 5.1.* || 5.2.*
- vinkla/hashids: ^2.2
Requires (Dev)
- graham-campbell/testbench: ^3.1
- phpunit/phpunit: ^4.8 || ^5.0
This package is auto-updated.
Last update: 2024-09-12 23:10:44 UTC
README
管理随机令牌以用于密码重置和其他一次性操作
安装
-
通过composer安装:
composer require infinety-es/token
-
将服务提供者添加到
config/app.php
Infinety\Token\TokenServiceProvider::class,
-
运行
php artisan token:migration
然后运行php artisan migrate
以添加Token数据库表
使用
- 令牌通过
Infinety\Token\Token
处理,可以通过容器实例化。示例
$token = new Token; $token->add($myId, 'test', 1)
- 令牌参数
- 引用: 令牌所引用的对象的整数ID,例如用户ID
- 类型: 字符串,确定令牌的类型
- 过期时间: 整数,确定令牌的有效时间(分钟),默认为null(永久有效)
Token::new(int $ref, string $type, int $expires = null)
返回一个40字符的hasID代码Token::find(string $code, string $type, bool $returnRef = true)
返回引用ID或null(如果$returnId为true),或Hashids解码的字符串Token::remove(string $code, string $type)
删除与代码关联的令牌(如果找到)