<?php 
namespace app\bsadmin\model;

use think\Model;

class Admin extends Model
{
    /**
     * 获取单个
     */
    public static function getAdmin($where='',$field='*')
    {
        return self::where($where)->field($field)->find();
    }
    /**
     * 获取单个
     */
    public static function editAdmin($where='')
    {
        return self::where($where)
            ->withoutField('password,password_hash,login_time,update_time,create_time')
            ->withAttr('allow_week',function($v,$d){
                return explode(",", $v);
            })
            ->find();
    }
    /**
     * 获取所有
     */
    public static function getSelect($where=[])
    {
        return self::where($where)->select();
    }
    /**
     * 获取所有
     */
    public static function getSelectField($where=[],$field="*")
    {
        return self::where($where)->select();
    }
    /**
     * [getAdminPassword 密码加密]
     * @param  string $hash     [description]
     * @param  string $password [description]
     * @return [type]           [description]
     */
    public static function getAdminPassword($hash='',$password='')
    {
        return md5(sha1(md5(strtoupper($hash).'&'.$password.'&'.$hash)));
    }
}