<?php
/**
 * gitee: https://gitee.com/kyle-cao/
 * Created by: admin.dadmin.cn
 * User: imdong
 * Date: 2018/11/21
 * Time: 11:42
 */

namespace app\common\logic;

use app\common\model\ManagerAuth as mManagerAuth;
use app\common\model\Role as mRole;

class ManagerAuth extends Base
{
    public function authIds()
    {

        $manager_access_token = request() -> param('manager_access_token');
        $manager_info = json_decode(decrypt($manager_access_token), true);
        $mManagerAuth = new mManagerAuth();
        $role_id = $mManagerAuth -> where('manager_id', '=', $manager_info['id']) -> value('role_id');
        if (empty($role_id)) {
            return [];
        }
        $mRole = new mRole();
        $auth_ids = $mRole -> where('id', '=', $role_id) -> value('auth_ids');
        if (empty($auth_ids)) {
            return [];
        }
        return explode(',', $auth_ids);
    }

    public function roleIds()
    {

        $manager_access_token = request() -> param('manager_access_token');
        $manager_info = json_decode(decrypt($manager_access_token), true);
        $mManagerAuth = new mManagerAuth();
        $role_ids = $mManagerAuth -> where('manager_id', '=', $manager_info['id']) -> value('role_id');
        if (empty($role_ids)) {
            return [];
        }
        return explode(',', $role_ids);
    }
}