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

Problem when we Deny Friend Request and send another request #111

Open
oza75 opened this issue Sep 9, 2018 · 0 comments
Open

Problem when we Deny Friend Request and send another request #111

oza75 opened this issue Sep 9, 2018 · 0 comments

Comments

@oza75
Copy link

oza75 commented Sep 9, 2018

Hi, and thanks for this package! I got some troubles. When you deny a friend request and sent another request, the canBeFriend method always return true. I take a look on your code and the problem was in

    /**
     * @param Model $recipient
     *
     * @return \Hootlex\Friendships\Models\Friendship
     */
    public function getFriendship(Model $recipient)
    {
        return $this->findFriendship($recipient)->first();
    }

This methods return the first request that was sent but if a first was denied the canBeFriend doesn't take care of it and then it's return true even if another request was sent.
I try to fix that by change the getFriendship method.

    /**
     * @param Model $recipient
     *
     * @return \Hootlex\Friendships\Models\Friendship
     */
    public function getFriendship(Model $recipient)
    {
        return $this->findFriendship($recipient)
            ->where('status', '<>', Status::DENIED)
            ->first();
    }

That solve my problem but i don't know if it cause another problem somewhere.

So this is the right way to solve this problem or there is another way

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

1 participant