| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace App\Services;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\Cache;
- trait AuthAdminUser
- {
- /**
- * 获取登录用户ID
- * @return int
- */
- public function getAuthUserId()
- {
- $user = $this->getAuthUser();
- return $user['id'];
- }
- /**
- * 获取公司ID
- * @return int
- */
- public function getAuthSalt()
- {
- $user = $this->getAuthUser();
- return $user['salt'];
- }
- /**
- * 获取公司ID
- * @return int
- */
- public function getAuthToken()
- {
- $user = $this->getAuthUser();
- return $user['token'];
- }
- /**
- * 获取登录用户
- * @return \Illuminate\Contracts\Auth\Authenticatable|null
- */
- public function getAuthUser()
- {
- // todo 用redis缓存来获取
- $user=Auth::user();
- return $user;
- }
- }
|