hasMany('UserAddress'); } /** * 关联收货地址表 (默认地址) * @return \think\model\relation\BelongsTo */ public function addressDefault() { return $this->belongsTo('UserAddress', 'address_id'); } /** * 显示性别 * @param $value * @return mixed */ public function getGenderAttr($value) { return $this->gender[$value]; } /** * 获取用户信息 * @param $where * @return null|static * @throws \think\exception\DbException */ public static function detail($where) { $filter = ['is_delete' => 0]; if (is_array($where)) { $filter = array_merge($filter, $where); } else { $filter['user_id'] = (int)$where; } return self::get($filter, ['address', 'addressDefault']); } }