I have a relationship through several staging tables. How to identify in Yii2?
So I tried to follow
public function getTbl1()
{
return $this->hasOne( Tbl1::className(), [ 'id' => 'tbl1_id' ] );
}
public function getTbl2()
{
return $this->hasOne( Tbl2::className(), [ 'id' => 'tbl2_id' ] )->via( 'tbl1' );
}
public function getTbl3()
{
return $this->hasOne( Tbl3::className(), [ 'id' => 'tbl3_id' ] )->via( 'tbl2' );
}
I get the ratio of tbl1 and tbl2 but cannot get tbl3. How can i do this?
Thanks in advance.
source
share