예제 #1
0
 /**
  * @param $id
  * @return null|UserProfileModel
  */
 protected function getUserProfile($id)
 {
     $user_profile = UserProfileModel::getProfile($id);
     if (!$user_profile) {
         $user_profile = new UserProfileModel();
         $user_profile->id = $id;
         // 保存
         $user_profile = UserProfileModel::createProfile($user_profile);
     }
     return $user_profile;
 }
예제 #2
0
 private function handleAvatar($auth_id)
 {
     $user_auth = UserAuthModel::getAuth($auth_id);
     if (!$user_auth) {
         throw new \Exception('用户不存在');
     }
     $user_profile = UserProfileModel::getProfile($user_auth->id);
     if (!$user_profile) {
         $user_profile = new UserProfileModel();
         $user_profile->id = $user_auth->id;
         // 保存
         $user_profile = UserProfileModel::createProfile($user_profile);
     }
     $request = $this->getRequest();
     $posts = $request->request;
     $avatar = $posts->get('avatar');
     $user_profile->avatar = $avatar;
     // 保存
     UserProfileModel::saveProfile($user_profile);
 }