public function getConfrimAdd(Friend $friend)
 {
     $sendFriend = Friend::where('user_id', $friend->friend_id)->where('friend_id', $friend->user_id)->where('type', false)->firstOrFail();
     $sendFriend->type = true;
     $sendFriend->save();
     $friend->is_confirm = true;
     $friend->type = true;
     $friend->save();
     return back()->with('flash_success', 'Вы успешно подружились.');
 }
 public function friend($hash)
 {
     $friend = Friend::where(['verification_hash' => $hash])->firstOrFail();
     $friend->markVerified();
     Log::info('Friend number verified: ' . print_r($friend, true));
     return "Verified!";
 }
 public function deleteFriend($id)
 {
     $user = Friend::where('friend_id', $id);
     $user->delete();
     flash()->error('Znajomy został usunięty!');
     return redirect('/profile/' . $id . '');
 }
示例#4
0
 public function accept(Request $request)
 {
     $friend = Friend::find($request->friendship_id);
     $friend->update(['status' => 1]);
     $this->stream($friend);
     return ['hasCallback' => 0, 'callback' => '', 'hasMsg' => 0, 'msg' => '', 'returns' => ['status' => 1]];
 }
示例#5
0
文件: User.php 项目: mikebywater/m8d8
 public function isMyFriend()
 {
     try {
         $friend = Friend::where('user_id', '=', \Auth::user()->id)->where('friend_id', '=', $this->id)->firstOrFail();
         return true;
     } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
         return false;
     }
 }
示例#6
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['pad_id' => 'required|integer|digits:9', 'captain_id' => 'required|max:4', 'captain_2_id' => 'required|max:4', 'need_id' => 'required|max:4', 'text' => 'required|max:50', 'g-recaptcha-response' => 'required|recaptcha']);
     $friend = new Friend();
     $friend->pad_id = Input::get('pad_id');
     $friend->captain_id = Input::get('captain_id');
     $friend->captainImgLink = Input::get('captain_id');
     $friend->captain_2_id = Input::get('captain_2_id');
     $friend->captain_2_idImgLink = Input::get('captain_2_id');
     $friend->need_id = Input::get('need_id');
     $friend->need_idImgLink = Input::get('need_id');
     $friend->text = Input::get('text');
     if ($friend->save()) {
         return Redirect::to('friend')->with('friend', friend::all());
     } else {
         return Redirect::back()->withInput()->withErrors('Something Error!!');
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $user = Auth::user();
     if ($user == null) {
         $user = User::find(1);
         Auth::login($user);
     }
     $friends = Friend::where('user_id', $user->id)->get();
     return view('friend.index')->withFriends($friends);
 }
示例#8
0
 public function store(Request $request)
 {
     $data['user_id'] = $request->user_id;
     $data['friend_id'] = \Auth::user()->id;
     Friend::firstOrCreate($data);
     // Create link the other way
     $data['user_id'] = \Auth::user()->id;
     $data['friend_id'] = $request->user_id;
     Friend::firstOrCreate($data);
     return redirect("users/{$request->user_id}");
 }
 public function friend($hash)
 {
     try {
         $friend = Friend::where(['verification_hash' => $hash])->firstOrFail();
     } catch (Exception $e) {
         return "Sorry, but we can't find that verification code.";
     }
     $friend->markVerified();
     Log::info('Friend number verified: ' . print_r($friend, true));
     return "Verified!";
 }
 public function getConfirmFriend($id)
 {
     $user = Friend::where(['user1_id' => Auth::id(), 'user2_id' => $id])->first();
     $handle = Friend::find($user->id);
     $handle->is_accepted = 1;
     $handle->save();
     $friend = Friend::where(['user2_id' => Auth::id(), 'user1_id' => $id])->first();
     $handle = Friend::find($friend->id);
     $handle->is_accepted = 1;
     $handle->save();
     return Redirect::back();
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($id = false)
 {
     if (!$id) {
         $id = Auth::user()->id;
     }
     $pivots = Friend::where('user_id', $id)->get();
     $friends = [];
     foreach ($pivots as $pivot) {
         $friend = User::find($pivot->friend_id);
         $json = ['id' => $friend->id, 'name' => $friend->name, 'email' => $friend->email, 'thumb_url' => $friend->thumb_url, 'about' => $friend->about, 'posts' => Post::where('authour_id', $friend->id)->get()];
         array_push($friends, $json);
     }
     return response()->json($friends);
 }
示例#12
0
 /**
  * получение информации о друзьях
  * @param  Request $r
  * @return
  */
 public function anyFriendsGet(Request $r)
 {
     $res = (new VK())->req('friends.get', $r->all());
     if (is_array($res) && !empty($res['count']) && $r->get('user_id')) {
         Friend::where('vk_id', $r->get('user_id'))->update(['count' => $res['count']]);
         // Список друзей
         $friendList = FriendList::select('vk_id')->where('owner_id', $r->get('user_id'))->where('is_friend', 1)->get()->lists('vk_id')->toArray();
         // список удаленных друзей
         $deletedFriend = FriendList::select('vk_id')->where('owner_id', $r->get('user_id'))->where('is_friend', 0)->get()->lists('vk_id')->toArray();
         $list = [];
         // новый друг которого добавим
         $list_ids = [];
         // id друзей данные с VK
         $flc = count($friendList) > 0;
         // Для ускорения проверки есть ли друзья у проверяемого пользователя
         $all = array_merge($friendList, $deletedFriend);
         // все друзья
         foreach ($res['items'] as $v) {
             $list_ids[] = $v['id'];
             if ($flc && in_array($v['id'], $all)) {
                 continue;
             }
             $list[] = ['owner_id' => $r->get('user_id'), 'vk_id' => $v['id'], 'first_name' => $v['first_name'], 'last_name' => $v['last_name'], 'photo_50' => $v['photo_50'], 'is_friend' => true, 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s")];
         }
         // удаленные
         $deleted = array_diff($friendList, $list_ids);
         if (count($deleted)) {
             FriendList::where('owner_id', $r->get('user_id'))->where('is_friend', 1)->whereIn('vk_id', $deleted)->update(['is_friend' => false]);
         }
         // вернувшиеся
         $added = array_diff($list_ids, $friendList);
         if (count($added)) {
             FriendList::where('owner_id', $r->get('user_id'))->where('is_friend', 0)->whereIn('vk_id', $added)->update(['is_friend' => true]);
         }
         if (count($list)) {
             FriendList::insert($list);
         }
         return resp(['count' => $res['count'], 'items' => FriendList::where('owner_id', $r->get('user_id'))->orderBy('is_friend')->orderBy('updated_at', 'DESC')->get()]);
     }
     return resp($res, 'Успешно выполнено', 'Запрос завершился ошибкой');
 }
 public function getRemoveFriend($id)
 {
     $authU = \Auth::user()->id;
     $friendinv = Friend::where('user_id', $id)->where('friend_id', $authU)->update(['state' => -1]);
     return redirect('profile/' . $authU);
 }
示例#14
0
 public function verifyFriendsNumber(Friend $friend, $key)
 {
     $friend->verification_hash = $key;
     $friend->save();
     return $this->twilio->text($friend->number, $this->friendsNumberVerificationMessage($key));
 }
示例#15
0
 public function myRequestsToOthers()
 {
     $friends = Friend::where(function ($query) {
         $query->where('sender_id', $this->current_user->id);
     })->where('status', 2)->get();
     #get friend info
     $friends = $friends->each(function ($item, $key) {
         $item->friend_info = User::find($item->receiver_id);
     });
     return $friends;
 }
示例#16
0
 /**
  * [add_friend description]
  * @param Request $request [description]
  */
 public function add_friend(Request $request)
 {
     $iiww = Friend::create(['user_1_id' => Auth::user()->id, 'user_2_id' => $request->user_2_id, 'accepted' => 0]);
     $user = User::findOrFail($request->user_2_id);
     return view('profile', compact('user'));
 }
 public function deleteFriend($id)
 {
     $userFriend = Friend::where('user_id', '=', $id)->where('friend_id', '=', Auth::user()->id);
     $userFriend->delete();
     $friendUser = Friend::where('user_id', '=', Auth::user()->id)->where('friend_id', '=', $id);
     $friendUser->delete();
 }
示例#18
0
 private function pushFriends($url, $client)
 {
     foreach (Friend::all() as $friend) {
         $json = ['id' => $friend->id, 'user_id' => $friend->user_id, 'friend_id' => $friend->friend_id];
         $client->post($url, ['json' => $json]);
     }
 }
示例#19
0
 public function friends()
 {
     return Friend::where('friend_id', $this->id)->get();
 }
示例#20
0
 public function getFollowingCount($id)
 {
     return Friend::where('follower_user_id', $id)->count();
 }
 public static function getFriendsAndUsersPosts()
 {
     $friends = Friend::where('user1_id', Auth::id())->where('is_accepted', 1)->get(['user2_id']);
     $friends->push(['user2_id' => Auth::id()]);
     $posts = Post::whereIn('author_id', $friends)->get();
     return $posts;
 }
 public function invitationReceived($id)
 {
     $user = Auth::user();
     $receiver = User::where('id', $id)->first();
     $result = Friend::where('invited_by', $receiver->id)->where(function ($query) use($receiver, $user) {
         $query->where(['user1_id' => $user->id, 'user2_id' => $receiver->id])->orWhere(['user1_id' => $receiver->id, 'user2_id' => $user->id]);
     })->get();
     return !$result->isEmpty();
 }
示例#23
0
 public function store()
 {
     $input = Friend::all();
     Friend::create($input);
     return $input;
 }