There are 3 tables in the database
Mobile operators
mobile_operatoridname -- НазваниеDedicated operator codes
national_mobile_codeidcode -- КодIntermediate table where links are stored
mo_nmc_keysidmobile_operator_idnational_mobile_code_id
CRUD generated trace code
<?php ... class MobileOperator extends \yii\db\ActiveRecord{ public function getMoNmcKeys(){ return $this->hasMany(MoNmcKeys::className(), ['mobile_operator_id' => 'id']); } ... } class NationalMobileCode extends \yii\db\ActiveRecord{ ... public function getRegNmcKeys(){ return $this->hasMany(RegNmcKeys::className(), ['national_mobile_code_id' => 'id']); } ... } class MoNmcKeys extends \yii\db\ActiveRecord{ ... public function getMobileOperator(){ return $this->hasOne(MobileOperator::className(), ['id' => 'mobile_operator_id']); } public function getNationalMobileCode(){ return $this->hasOne(MoNmcKeys::className(), ['id' => 'national_mobile_code_id']); } public function getMoNmcKeys(){ return $this->hasMany(MoNmcKeys::className(), ['national_mobile_code_id' => 'id']); } ... } How can I display the data with operator codes on the mobile operators page in GridView Or, in other words, how to get data through an intermediate table