hootlex / laravel-friendships

This package gives Eloquent models the ability to manage their friendships.
MIT License
706 stars 151 forks source link

Call to undefined method App\User::getPendingsCount() #119

Open bhdrnzl opened 5 years ago

bhdrnzl commented 5 years ago

controller; $user = User::find(Auth::id());

blade; {{ $user->getPendingsCount() }}

error; Call to undefined method App\User::getPendingsCount()

TechTailor commented 5 years ago

First of all, use this for getting the currently logged in user. Its much clean. $user = Auth::user();

Secondly, , the getPendingsCount() function was probably removed as I can't find it in the code and I guess the ReadMe was never updated for it.

You can use a function as this one to get the same results (add the following to vendor\hootlex\laravel-friendships\src\Traits\Friendable.php;

public function getPendingFriendsCount($groupSlug = '')
    {
        $friendsCount = $this->findFriendships(Status::PENDING, $groupSlug)->count();
        return $friendsCount;
    }

However I have not tested it. Will create a PR when I get home after testing.

-TT

samiklah commented 5 years ago

check out your User model you are calling an undefined method