<?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;
    }

}
