trying to execute the following query on the FriendController
$friends = Auth::User()->friends;
and that is the friends function on the User model
public function friends()
{
return $this->belongsToMany('App\Friend', 'friends', 'user_id', 'friend_id');
}
but on hitting the route i get the following error
Illuminate \ Database \ QueryException (42000) SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'friends' (SQL: select
friends
.*,friends
.user_id
aspivot_user_id
,friends
.friend_id
aspivot_friend_id
fromfriends
inner joinfriends
onfriends
.id
=friends
.friend_id
wherefriends
.user_id
= 2)