修改权限模型

This commit is contained in:
wuyanwen
2020-01-14 08:23:29 +08:00
parent b6b0b5170d
commit 2acf23d296
2 changed files with 58 additions and 58 deletions

View File

@@ -49,4 +49,20 @@ class Permissions extends CatchModel
{
return $this->belongsToMany(Roles::class, 'role_has_permissions', 'role_id', 'permission_id');
}
/**
* 获取当前用户权限
*
* @time 2020年01月14日
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @return \think\Collection
*/
public static function getCurrentUserPermissions(): \think\Collection
{
return parent::whereIn('id', request()->user()->getPermissionsBy())
->field(['permission_name as title', 'route', 'icon'])
->select();
}
}