Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $val = request()->validate([
- 'mobileNumber' => 'required|min:1|max:16',
- ]);
- $user = User::where('mobileNumber',$val['mobileNumber'])->whereNotIn('mobileNumber',[Auth::user()->mobileNumber])->first();
- $alredyFriend = FriendList::where('userId', '=', Auth::user()->id)->where('friendId', '=', Auth::user()->id)
- ->orWhere(function ($friendList) {
- $friendList->where('status','Friend');
- })->get();
- $friend = array();
- foreach ($alredyFriend as $value) {
- $friend[] = $value['userId'];
- $friend[] = $value['friendId'];
- }
- if(in_array($user['id'], $friend)) {
- return back()->with('error','it`s already friend list..!');
- }
- $requestFriend = FriendList::where('userId', '=', Auth::user()->id)->where('friendId', '=', Auth::user()->id)
- ->orWhere(function ($friendList) {
- $friendList->where('status','Request');
- })->get();
- $reqFriend = array();
- foreach ($requestFriend as $value) {
- $reqFriend[] = $value['userId'];
- $reqFriend[] = $value['friendId'];
- }
- if(in_array($user['id'], $reqFriend)) {
- return back()->with('error','it`s already sended friend request..!');
- }
- $blockFriend = FriendList::where('userId', '=', Auth::user()->id)->where('friendId', '=', Auth::user()->id)
- ->orWhere(function ($friendList) {
- $friendList->where('status','Block');
- })->get();
- $blFriend = array();
- foreach ($blockFriend as $value) {
- $blFriend[] = $value['userId'];
- $blFriend[] = $value['friendId'];
- }
- if(in_array($user['id'], $blFriend)) {
- return back()->with('error','it`s blocked user..!');
- }
- if(count($user)) {
- return back()->with('error','are you not send friend request to you..!');
- }
Add Comment
Please, Sign In to add comment