Closed AzeemMichael closed 8 years ago
It depends on whether you're using belongsToMany (incoming) or hasMany (outgoing).
User A follows user B means A hasMany followers, yet B is followed by A means followedBy is an incoming relationship towards B.
Hope this makes it clear to you.
@Mulkave Thanks, using hasMany() on User side worked. Following Eloquent docs, I assumed we use belongsToMany() on both sides of the relationship for ManyToMany. i.e.,:
class User extends NeoEloquent {
public function roles() {
$this->belongsToMany(Role::class, 'ROLE');
}
}
class Role extends NeoEloquent {
public function users() {
$this->belongsToMany(User::class, 'ROLE');
}
}
I noticed One-To-One and One-To-Many are both outgoing relationships. But, Many-To-Many is an Incoming relationship. Shouldn't it be an Outgoing too? if User A follows User B. Shouldn't the relation be from A to B. It's A follows B, not, B follows A.