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