protected function findModel($id)
 {
     if (($model = FieldValueVariant::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested variant does not exist.');
     }
 }
 public function search($params)
 {
     $query = FieldValueVariant::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'field_id' => $this->field_id]);
     $query->andFilterWhere(['like', 'value', $this->value]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 public static function editField($id, $name, $value)
 {
     $setting = FieldValueVariant::findOne($id);
     $setting->{$name} = $value;
     $setting->save();
 }
Ejemplo n.º 4
0
 public function getVariants()
 {
     return $this->hasMany(FieldValueVariant::className(), ['field_id' => 'id']);
 }