public function testCreateAttributes() { foreach ($this->dataAttr() as $values) { $attr = new EavAttribute(); $attr->attributes = $values; $attr->save(); } $this->assertEquals(EavAttribute::find()->count(), 3); $k = 0; foreach ($this->dataAttr() as $values) { $k++; foreach ($values as $key => $value) { $this->assertEquals(EavAttribute::findOne(['id' => $k])->{$key}, $value); } } }
/** * @return \yii\db\ActiveQuery */ public function getAttribute($name = '') { return $this->hasOne(EavAttribute::className(), ['id' => 'attributeId']); }
/** * @return \yii\db\ActiveQuery */ public function getEavAttributes() { return $this->hasMany(EavAttribute::className(), ['categoryId' => 'categoryId']); }
/** * @return \yii\db\ActiveQuery */ public function getEavAttributes() { return $this->hasMany(EavAttribute::className(), ['entityId' => 'id']); }
public function canGetProperty($name, $checkVars = true) { return EavAttribute::find()->where(['name' => $name])->exists(); }