コード例 #1
0
ファイル: BehaviorTest.php プロジェクト: mazurva/yii2-eav
 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);
         }
     }
 }
コード例 #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAttribute($name = '')
 {
     return $this->hasOne(EavAttribute::className(), ['id' => 'attributeId']);
 }
コード例 #3
0
ファイル: EavEntity.php プロジェクト: mazurva/yii2-eav
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEavAttributes()
 {
     return $this->hasMany(EavAttribute::className(), ['categoryId' => 'categoryId']);
 }
コード例 #4
0
ファイル: EavEntity.php プロジェクト: mazurva/yii2-eav
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEavAttributes()
 {
     return $this->hasMany(EavAttribute::className(), ['entityId' => 'id']);
 }
コード例 #5
0
ファイル: EavBehavior.php プロジェクト: mazurva/yii2-eav
 public function canGetProperty($name, $checkVars = true)
 {
     return EavAttribute::find()->where(['name' => $name])->exists();
 }