<?php 
namespace app\bsadmin\model;

use think\Model;

class Role extends Model
{
	/**
	 * 获取所有
	 */
	public static function getSelect($where=[])
	{
		return self::where($where)->select();
	}
	/**
	 * 获取所有
	 */
	public static function getCateList($where=[])
	{
		return self::field('rid,title')->select();
	}
	/**
	 * 获取单个
	 */
	public static function getRole($where='',$field='*')
	{
		return self::where($where)->field($field)
		->withAttr('auth',function($v,$d){
			if ($v) {
				$auth=[];
				foreach (explode(",",$v) as $k => $v) {
					$auth[]=intval($v);
				}
				return $auth;
			}else{
				return [];
			}
		})->find();
	}
}