I\'m trying to create a Friendship system with Laravel (I\'m starting with it) but I\'m blocked with relationships. Here\'s the thing : there is one table Users and one tabl
It's oviously a problem in your DB and also definition of the relation. Many-to-Many relation type expects you to use and intermediate table. Here's what you have to do :
user_friend (id, user_id, friend_id)
table in your schema.user
and friend
tables.user.id
-> user_friend.user_id
, friend.id
-> user_friend.friend_id
for example :
class User extends Eloquent {
function friends()
{
return $this->belongsToMany('User', 'user_friend', 'user_id', 'friend_id');
}
}
You can read much more in Laravel docs, HERE