true, 'targetClass' => Product::className(), 'targetAttribute' => [ 'product_id' => 'id' ], ], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'product_id' => Yii::t('catalog', 'Product ID'), 'image_id' => Yii::t('catalog', 'Image ID'), ]; } /** * @return \yii\db\ActiveQuery */ public function getImage() { return $this->hasOne(Image::className(), [ 'id' => 'image_id' ]) ->inverseOf('productToImages'); } /** * @return \yii\db\ActiveQuery */ public function getProduct() { return $this->hasOne(Product::className(), [ 'id' => 'product_id' ]) ->inverseOf('productToImages'); } }