origin; } protected static function init() { /*self::beforeUpdate(function ($row) { $changed = $row->getChangedData(); //如果有修改密码 if (isset($changed['password'])) { if ($changed['password']) { $salt = \fast\Random::alnum(); $row->password = \app\common\library\Auth::instance()->getEncryptPassword($changed['password'], $salt); $row->salt = $salt; } else { unset($row->password); } } });*/ /*self::beforeUpdate(function ($row) { $changedata = $row->getChangedData(); if (isset($changedata['score'])) { $origin = $row->getOriginData(); ScoreLog::create(['user_id' => $row['id'], 'score' => $changedata['score'] - $origin['score'], 'before' => $origin['score'], 'after' => $changedata['score'], 'memo' => '管理员变更积分']); } });*/ } public function getGenderList() { return ['1' => __('Male'), '0' => __('Female')]; } public function getStatusList() { return ['normal' => __('Normal'), 'hidden' => __('Hidden'), 'cancel' => __('Cancel')]; } public function getNeedCheckList() { return [0 => __('Need_check 0'), 1 => __('Need_check 1')]; } public function getNeedCheckTextAttr($value, $data) { $value = $value ? $value : (isset($data['need_check']) ? $data['need_check'] : ''); $list = $this->getNeedCheckList(); return isset($list[$value]) ? $list[$value] : ''; } public function getPrevtimeTextAttr($value, $data) { $value = $value ? $value : $data['prevtime']; return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getLogintimeTextAttr($value, $data) { $value = $value ? $value : $data['logintime']; return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getJointimeTextAttr($value, $data) { $value = $value ? $value : $data['jointime']; return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } protected function setPrevtimeAttr($value) { return $value && !is_numeric($value) ? strtotime($value) : $value; } protected function setLogintimeAttr($value) { return $value && !is_numeric($value) ? strtotime($value) : $value; } protected function setJointimeAttr($value) { return $value && !is_numeric($value) ? strtotime($value) : $value; } protected function setBirthdayAttr($value) { return $value ? $value : null; } public function getIsCoolList() { return ['0' =>__('Is_cool 0'), '1' =>__('Is_cool 1')]; } public function getIsCoolTextAttr($value, $data) { $value = $value ? $value : (isset($data['is_cool']) ? $data['is_cool'] : ''); $list = $this->getIsCoolList(); return isset($list[$value]) ? $list[$value] : ''; } public function getIsManagerList() { return ['0' =>__('Is_manager 0'), '1' =>__('Is_manager 1')]; } public function getIsManagerTextAttr($value, $data) { $value = $value ? $value : (isset($data['is_manager']) ? $data['is_manager'] : ''); $list = $this->getIsManagerList(); return isset($list[$value]) ? $list[$value] : ''; } public function getIsStealthList() { return ['0' =>__('Is_stealth 0'), '1' =>__('Is_stealth 1')]; } public function getIsStealthTextAttr($value, $data) { $value = $value ? $value : (isset($data['is_stealth']) ? $data['is_stealth'] : ''); $list = $this->getIsStealthList(); return isset($list[$value]) ? $list[$value] : ''; } public function noble() { return $this->belongsTo('app\admin\model\noble\Level', 'noble', 'id', [], 'LEFT')->setEagerlyType(0); } public function preuser() { return $this->belongsTo('app\admin\model\User', 'pre_userid', 'id', [], 'LEFT')->setEagerlyType(0); } public function auth() { return $this->belongsTo('app\admin\model\user\Auth', 'id', 'user_id', [], 'LEFT')->setEagerlyType(0); } public function age() { return $this->belongsTo('app\admin\model\Age', 'age_id', 'id', [], 'LEFT')->setEagerlyType(0); } public function constellation() { return $this->belongsTo('app\admin\model\Constellation', 'constellation_id', 'id', [], 'LEFT')->setEagerlyType(0); } public function getUinqueId($length = 8, $ids = []) { $newid = Random::build("nozero", $length); if (in_array($newid, $ids)) { $newid = $this->getUinqueId($length, $ids); } return $newid; } /** * 生成不重复的随机数字字母组合 */ function getUinqueNo($length = 8, $nos = []) { $newid = Random::build("alnum", $length); if (in_array($newid, $nos)) { $newid = $this->getUinqueNo($length, $nos); } return $newid; } }