Skip to content

ChangeLog v1.2.4

Compare
Choose a tag to compare
@Tinywan Tinywan released this 20 Apr 02:37
· 61 commits to main since this release

Full Changelog: v1.2.3...v1.2.4

支持获取当前用户信息(模型),支持LaravelORM和ThinkORM

$user = Tinywan\Jwt\JwtToken::getUser();

该配置项目'user_model'为一个匿名函数,默认返回空数组,可以根据自己项目ORM定制化自己的返回模型

ThinkORM 配置

'user_model' => function($uid) {
// 返回一个数组
return \think\facade\Db::table('resty_user')
  ->field('id,username,create_time')
  ->where('id',$uid)
  ->find();
  }

LaravelORM 配置

'user_model' => function($uid) {
// 返回一个对象
return \support\Db::table('resty_user')
  ->where('id', $uid)
  ->select('id','email','mobile','create_time')
  ->first();
}