1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-23 20:00:27 +08:00
course-tencent-cloud/app/Models/RefreshToken.php
2020-04-09 18:44:46 +08:00

73 lines
1011 B
PHP

<?php
namespace App\Models;
class RefreshToken extends Model
{
/**
* 主键编号
*
* @var string
*/
public $id;
/**
* 用户编号
*
* @var int
*/
public $user_id;
/**
* 回收标识
*
* @var int
*/
public $revoked;
/**
* 过期时间
*
* @var int
*/
public $expiry_time;
/**
* 创建时间
*
* @var int
*/
public $create_time;
/**
* 更新时间
*
* @var int
*/
public $update_time;
public function getSource()
{
return 'kg_refresh_token';
}
public function beforeCreate()
{
$this->id = $this->getRandId($this->user_id);
$this->create_time = time();
}
public function beforeUpdate()
{
$this->update_time = time();
}
protected function getRandId($userId, $prefix = 'RT')
{
return md5("{$prefix}-{$userId}" . time() . rand(1000, 9999));
}
}