Answer the question
In order to leave comments, you need to log in
How to exclude records from ActiveRecord whose id is obtained in another ActiveRecord?
There is a table of users Users
There is a table of user groups Groups
There is a table for linking users and groups group_users
There is a getUsers() method in the Groups model
public function getUsers()
{
return $this->hasMany(Users::className(), ['id' => 'user_id'])->via('groupUsers');
}
public function getUsers()
{
return $this->hasMany(Users::className(), ['id' => 'user_id'])->via('teamUsers');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question