Ejemplo n.º 1
0
 /**
  * 获得在线好友
  *
  * @param $params array 用户登录名和密码参数
  * @return int
  * @author yangyifan <*****@*****.**>
  */
 public static function onlineUser()
 {
     load_func('instanceof,image,common');
     $online_user = get_redis()->hGetAll(config('config.user_list_hash_table'));
     $item = [];
     //获得全部我的好友
     $my_friends = FriendsModel::getMyFriends();
     foreach ($online_user as $user) {
         $user = unserialize($user);
         //如果是自己,则跳过 || 如果不是自己好友,则跳过
         if ($user->id == is_user_login() || !in_array($user->id, $my_friends)) {
             continue;
         }
         $item[] = ['id' => $user->id, 'name' => $user->user_name, 'face' => get_user_info_face($user->face), 'url' => action("User\\UserController@getIndex", ['id' => $user->id])];
     }
     $data = [['name' => '在线好友', 'nums' => count($item), 'id' => 1, 'item' => $item]];
     return $data;
 }
 /**
  * 确认添加好友请求
  *
  * @param Request $request
  * @author yangyifan <*****@*****.**>
  */
 public function postConfirmAddFriend(Request $request)
 {
     $status = FriendsModel::confirmAddFriend(intval($request->get('user_id')), intval($request->get('letter_id')));
     $status == true ? $this->response(200, trans('response.confirm_add_friend_success')) : $this->response(400, trans('response.page_error'));
 }