i have this error i use laravel 5.3 Call to undefined method Illuminate\Auth\GenericUser::hasFriendRequestPending() can anyone help me please ?!!
User Model
public function friendsOfMine()
{
return $this->belongsToMany('App\User', 'friends' , 'user_id' , 'friend_id');
}
public function friendOf(){
return $this->belongsToMany('App\User', 'friends' , 'friend_id' , 'user_id' );
}
public function friendRequestsPending()
{
return $this->friendOf()->wherePivot('accepted' , false)->get();
}
public function hasFriendRequestPending(User $user)
{
return (bool) $this->friendRequestsPending()->where('id' , $user->id)->count();
}
in view
<h4>Friend Requests</h4>
@if (Auth::user()->hasFriendRequestPending($user))
<p>Waiting For {{$user->username}} To Accept Your Request. </p>
@endif
auth.php
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
Your error is that the method hasFriendRequestsPending()
is not defined. But the name of your function is actually hasFriendRequestPending()
.
Try to find where you call for hasFriendRequestsPending()
and change it to hasFriendRequestPending()
.
You can also check if in your config/auth.php, you set the correct provider:
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],