Guest User

Untitled

a guest
Jan 10th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. $val = request()->validate([
  2. 'mobileNumber' => 'required|min:1|max:16',
  3. ]);
  4.  
  5. $user = User::where('mobileNumber',$val['mobileNumber'])->whereNotIn('mobileNumber',[Auth::user()->mobileNumber])->first();
  6.  
  7. $alredyFriend = FriendList::where('userId', '=', Auth::user()->id)->where('friendId', '=', Auth::user()->id)
  8. ->orWhere(function ($friendList) {
  9. $friendList->where('status','Friend');
  10. })->get();
  11.  
  12. $friend = array();
  13. foreach ($alredyFriend as $value) {
  14. $friend[] = $value['userId'];
  15. $friend[] = $value['friendId'];
  16. }
  17.  
  18. if(in_array($user['id'], $friend)) {
  19. return back()->with('error','it`s already friend list..!');
  20. }
  21.  
  22. $requestFriend = FriendList::where('userId', '=', Auth::user()->id)->where('friendId', '=', Auth::user()->id)
  23. ->orWhere(function ($friendList) {
  24. $friendList->where('status','Request');
  25. })->get();
  26.  
  27. $reqFriend = array();
  28. foreach ($requestFriend as $value) {
  29. $reqFriend[] = $value['userId'];
  30. $reqFriend[] = $value['friendId'];
  31. }
  32.  
  33. if(in_array($user['id'], $reqFriend)) {
  34. return back()->with('error','it`s already sended friend request..!');
  35. }
  36.  
  37. $blockFriend = FriendList::where('userId', '=', Auth::user()->id)->where('friendId', '=', Auth::user()->id)
  38. ->orWhere(function ($friendList) {
  39. $friendList->where('status','Block');
  40. })->get();
  41.  
  42. $blFriend = array();
  43. foreach ($blockFriend as $value) {
  44. $blFriend[] = $value['userId'];
  45. $blFriend[] = $value['friendId'];
  46. }
  47.  
  48. if(in_array($user['id'], $blFriend)) {
  49. return back()->with('error','it`s blocked user..!');
  50. }
  51.  
  52. if(count($user)) {
  53. return back()->with('error','are you not send friend request to you..!');
  54. }
Add Comment
Please, Sign In to add comment