If we have multiple relation via more than 1 relation, we get an exception in yii\db\ActiveQuery::getModelKey($model, $attributes) when yii\db\ActiveQuery::populateRelation trying to get a $key for the $link.
Example:
class User extends yii\db\ActiveRecord
{
//...
public function getSessionPlayground()
{
return $this->hasOne(Playground::class, ['id' => 'playground_id'])
->viaTable('user_session via_user_session', ['id' => 'last_user_session_id'])
}
public function getSesionPlaygroundType()
{
return $this->hasOne(PlaygroundType::class, ['id' => 'playground_type_id'])
->via('sessionPlayground');
}
In this case $link = ['playground_id'] and \db\ActiveQuery::getModelKey(User, ['playground_id']) throwing an exception that playground_id is unknown property for User.
Hey everybody!
If we have multiple relation via more than 1 relation, we get an exception in
yii\db\ActiveQuery::getModelKey($model, $attributes)
whenyii\db\ActiveQuery::populateRelation
trying to get a$key
for the$link
.Example:
In this case
$link = ['playground_id']
and\db\ActiveQuery::getModelKey(User, ['playground_id'])
throwing an exception thatplayground_id
is unknown property forUser
.