s22.postimg.org/xb03rcg9t/diagram.png
I have a table called User and a junction table called Friend uniting User to itself.
I have these two classes User and Friend and I put this code inside of User:
public function getFriends()
{
return $this->hasMany(Friend::className(), ['userId' => 'id'])->viaTable('friend', ['friendId' => 'id']);
}
I have nothing in the model Friend, because Friend is a junction table. Would this work? There are no pointers in the documentation for particular cases like this one.