true, 'targetClass' => Product::className(), 'targetAttribute' => [ 'product_id' => 'id' ], ], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => Yii::t('app', 'ID'), 'product_id' => Yii::t('app', 'Product ID'), 'value' => Yii::t('app', 'Value'), ]; } /** * @return \yii\db\ActiveQuery */ public function getProduct() { return $this->hasOne(Product::className(), [ 'id' => 'product_id' ]); } /** * @inheritdoc */ public function getLinkAttribute(): string { return 'product_id'; } /** * @inheritdoc */ public function getValue(): float { return $this->value; } /** * @inheritdoc */ public function setValue(float $value) { $this->value = $value; } }