where('uid', $row['id']) ->column('group_id'); } public function getGroupNameArrAttr($value, $row) { $groupAccess = Db::name('admin_group_access') ->where('uid', $row['id']) ->column('group_id'); return AdminGroup::whereIn('id', $groupAccess)->column('name'); } public function getAvatarAttr($value) { return full_url($value, true, Config::get('buildadmin.default_avatar')); } public function getLastlogintimeAttr($value) { return $value ? date('Y-m-d H:i:s', $value) : 'none'; } /** * 重置用户密码 * @param int $uid 管理员ID * @param string $newPassword 新密码 */ public function resetPassword($uid, $newPassword) { $salt = Random::build('alnum', 16); $passwd = encrypt_password($newPassword, $salt); return $this->where(['id' => $uid])->update(['password' => $passwd, 'salt' => $salt]); } public function department() { return $this->belongsTo(Department::class); } public function jobs() { return $this->belongsTo(Jobs::class); } }