|
@@ -17,12 +17,12 @@ class User extends Model
|
|
|
protected $updateTime = 'updatetime';
|
|
|
// 追加属性
|
|
|
protected $append = [
|
|
|
- 'age_text',
|
|
|
+ /*'age_text',
|
|
|
'constellation_text',
|
|
|
'province_text',
|
|
|
'city_text',
|
|
|
'friends_num',
|
|
|
- 'look_num',
|
|
|
+ 'look_num',*/
|
|
|
];
|
|
|
|
|
|
public function getAgeTextAttr($value, $data)
|
|
@@ -443,11 +443,35 @@ class User extends Model
|
|
|
|
|
|
return $res;
|
|
|
}
|
|
|
+
|
|
|
+ public function getAppendData(&$userInfo=[])
|
|
|
+ {
|
|
|
+ if (!empty($userInfo)) {
|
|
|
+ $userId = isset($userInfo['id']) ? $userInfo['id'] : 0;
|
|
|
+ $ageId = isset($userInfo['age_id']) ? $userInfo['age_id'] : 0;
|
|
|
+ $constellationId = isset($userInfo['constellation_id']) ? $userInfo['constellation_id'] : 0;
|
|
|
+ $provinceId = isset($userInfo['province_id']) ? $userInfo['province_id'] : 0;
|
|
|
+ $cityId = isset($userInfo['city_id']) ? $userInfo['city_id'] : 0;
|
|
|
+ $userInfo['age_text'] = $this->getAgeTextAttr(false,['age_id' => $ageId]);
|
|
|
+ $userInfo['constellation_text'] = $this->getConstellationTextAttr(false,['constellation_id' => $constellationId]);
|
|
|
+ $areaWhere['id'] = ['in',[$provinceId,$cityId]];
|
|
|
+ $areaData = Db::name('shopro_area')->where($areaWhere)->column('id,name');
|
|
|
+ $userInfo['province_text'] = isset($areaData[$provinceId]) ? $areaData[$provinceId] : '';
|
|
|
+ $userInfo['city_text'] = isset($areaData[$cityId]) ? $areaData[$cityId] : '';
|
|
|
+ $userInfo['friends_num'] = $this->getFriendsNumAttr(false,['id' => $userId]);
|
|
|
+ $userInfo['look_num'] = $this->getLookNumAttr(false,['id' => $userId]);
|
|
|
+ }
|
|
|
+ return $userInfo;
|
|
|
+ }
|
|
|
|
|
|
public function age()
|
|
|
{
|
|
|
return $this->hasOne('Age', 'id', 'age_id',[],'LEFT');
|
|
|
}
|
|
|
+ public function constellation()
|
|
|
+ {
|
|
|
+ return $this->hasOne('Constellation', 'id', 'constellation_id',[],'LEFT');
|
|
|
+ }
|
|
|
public function useralipay()
|
|
|
{
|
|
|
return $this->hasOne('UserAlipay', 'user_id', 'id',[],'LEFT');
|