File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -71,19 +71,18 @@ public function deleteFriend($user)
71
71
72
72
public function friends ()
73
73
{
74
- $ recipients = Friendship::whereSender ($ this )
75
- ->accepted (1 )
76
- ->get (['user_requested ' ])
77
- ->toArray ();
78
-
79
- $ senders = Friendship::whereRecipient ($ this )
80
- ->accepted (1 )
81
- ->get (['requester ' ])
82
- ->toArray ();
74
+ $ friendsIds = Friendship::where (function ($ query ) {
75
+ $ query ->whereSender ($ this );
76
+ })->orWhere (function ($ query ) {
77
+ $ query ->whereRecipient ($ this );
78
+ })->accepted (1 )->get (['user_requested ' , 'requester ' ])->toArray ();
83
79
84
- $ friendsIds = array_merge ($ recipients , $ senders );
80
+ $ friendsIds = collect ($ friendsIds )->flatten ()->unique ()->reject (function ($ id ) {
81
+ return $ id == $ this ->id ;
82
+ });
85
83
86
84
return static ::whereIn ('id ' , $ friendsIds )
85
+ ->distinct ()
87
86
->get ();
88
87
}
89
88
You can’t perform that action at this time.
0 commit comments