I have created this method in the Users model to get all the replies that link to the current user
public function getAllRepliesForUsers()
{
return $this->hasMany(Replies::class, ['user_id' => 'id'])->viaTable('replies_links', ['replies_id' => 'id'])->where(['entity'=>'user']);
}
Replies photo
users table image - Joxi (731 kb) закачан 8 июля 2022 г. Joxi
table that links 2 these tables - Joxi (186 kb) закачан 8 июля 2022 г. Joxi
Is my variant of method is correct, is my method in the correct model?