diff --git a/application/common/library/Auth.php b/application/common/library/Auth.php index 91a7e5072a90d71c630e187bff414f68e2376e30..e6108d7ec2793d2a6171210214b18d7b4f7bcfd6 100644 --- a/application/common/library/Auth.php +++ b/application/common/library/Auth.php @@ -50,6 +50,28 @@ class Auth return self::$instance; } + /** + * 获取当前登录用户id,未登录返回null + * + * @return null + */ + public static function id() + { + $user = self::instance()->getUser(); + + return $user ? $user->id : null; + } + + /** + * 获取当前登录用户模型 + * + * @return User + */ + public static function user() + { + return self::instance()->getUser(); + } + /** * 获取User模型 * @return User