<?php
/**
 * Created by PhpStorm.
 * User: tandunzhao
 * Date: 2017/12/22
 * Time: 下午1:41
 */

namespace App\Http\Controllers\Cp;

use App\Http\Controllers\Controller;

class BaseController extends Controller
{


    //获取当前登录用户ID
    function getLoginUserId() {
        if(empty(session('cp_manage_user'))) {
            if(env('APP_ENV') =='local') return 1;
        }

        $user = unserialize(session('cp_manage_user'));
        return $user->id;
    }

    //获取当前登录用户角色
    function getLoginUserRole() {
        if(empty(session('cp_manage_user'))) {
            if(env('APP_ENV') =='local') return 'admin';
        }

        $user = unserialize(session('cp_manage_user'));
        return $user->role;
    }

    function getLoginUser() {
        if(empty(session('cp_manage_user'))) {
            if(env('APP_ENV') =='local') return '';
        }

        $user = unserialize(session('cp_manage_user'));
        return $user;
    }
}