Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getPendingFriends #56

Open
nikolaynesov opened this issue Sep 29, 2016 · 7 comments
Open

getPendingFriends #56

nikolaynesov opened this issue Sep 29, 2016 · 7 comments

Comments

@nikolaynesov
Copy link
Contributor

Hey,

We have already got getFriends() function to get Users with Friendship ACCEPTED status and other methods like getMutualFriends(), getFriendsOfFriends() . How about to introduce getPendingFriends to get Users (not friendships model like we do in getPendingFriendships()) ?
I want to show a list of pendings friends with some user info that I need get from the User Model and a button to accept the friendship request with a clean and easy method? What do you think? Or maybe I missed something?

@hootlex
Copy link
Owner

hootlex commented Sep 29, 2016

Hi @nikolaynesov,
It sounds good to me. What do you expect getPendingFriends to return?
The pending friends that the user has sent a friend request to or the pending friends despite if the user sent or received the friend request?

@nikolaynesov
Copy link
Contributor Author

nikolaynesov commented Sep 29, 2016

@hootlex I am expecting to get Users that sent requests to Current User but their requests are still not ACCEPTED. Right now in my controller I temporary do it like this:

public function ajaxGetPendingFriends() {

        $friendships    = Auth::user()->getPendingFriendships();
        $senders        = $friendships->pluck('sender_id')->all();
        $query          = User::where('id', '!=', Auth::user()->id)->whereIn('id', $senders);
        $pendingFriends = $query->paginate($this->friendsPerPage);

        return response()->json($pendingFriends);

    }

But it's a bit wrong and not efficient because getPendingFriendships() returns all friendships and not only where current user is recipient so then I need to use WHERE for user query to exclude current user... looks like we need another querybuilder method?
BTW how is it going with #16 ? is it going to solve my issue and make the package more flexible?

@nikolaynesov
Copy link
Contributor Author

nikolaynesov commented Sep 29, 2016

Another thing is what if I want to make an auto-complete ajax search by pending friends, declined friends, accepted friends or friends in some group? ))) It means we need a more flexible way to build queries. Should it look something like:

$user->friends()->accepted()->group('close_friends')
$user->friends()->pending()->search('John S')

@hootlex
Copy link
Owner

hootlex commented Sep 29, 2016

A more flexible API is definitely needed. Unfortunately, @stephane-monnot and I, are too busy at the moment. I will probably start working on #16 next month.

Regarding your current situation, I suggest to create two temporary methods to use until we go to V2:

  • getPendingIncomingFriends
  • getPendingOutgoingFriends

BTW, I think that V2 deserves a decent documentation. I'd be glad if you guys could help me when the time comes. 😄

@hootlex
Copy link
Owner

hootlex commented Oct 8, 2016

@nikolaynesov are you going to implement these methods before the v2?

@nikolaynesov
Copy link
Contributor Author

@hootlex not sure yet, but will let you know by Friday.

@TechTailor
Copy link

@hootlex facing this same issue myself. Need to load details of users whose who have not yet accepted my friendship but getPendingFriendships() returns all instances regardless of whether the current user is the sender or recipient as such I cannot eager load getPendingFriendships()->load('recipient') the result as the current user themselves will show up in the list.

Would really love a method that would return all pending requests either sent by me or sent to me with User details.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants