<?php
namespace App\Models;
class Token extends BaseModel {
	protected $table = "account_token";
	public $timestamps = false;

   
    //获取管理员角色
    function getUserToken(){
		$data = $this->paginate(10);
		return $data->toArray();
        if(!empty($where)&&count($where)>0){
            $data = $this->where($where)->orderBy('create_at','desc')->paginate($list);
        }else{
            $data=$this->orderBy('create_at','desc')->paginate($list);
        }
        return $data->toArray();
    }
    //
    function getRoleBy($admin_id){
        $data=$this->select('role_name')->where('admin_id',$admin_id)->get();
        if(!$data){
            return '';
        }
        return $data->toArray();
    }
    function getRoleIn($ids){
        $data=$this->whereIn('admin_id',$ids)->get();
        if(!$data){
            return array();
        }
        return $data->toArray();
    }
    //查询管理员有有的角色
    function gethasRole($admin_id){
        $data=$this->select('role_id')
            ->where('admin_id',$admin_id)
            ->get();
        $arr=array();
        if(!$data){
            return $arr;
        }
        $data=$data->toArray();

        foreach ($data as $v){
            $arr[]=$v['role_id'];
        }
        return $arr;
    }
    //
    function addRole($data){
        $res=$this->insert($data);
        if(!$res){
            return -7050021922;//添加角色失败
        }
        return 1;
    }

}