lundi 16 juillet 2018

Illuminate \ Database \ QueryException (42000) SQLSTATE[42000]: Syntax error or access violation

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 as pivot_user_id, friends.friend_id as pivot_friend_id from friends inner join friends on friends.id = friends.friend_id where friends.user_id = 2)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire