protected function findModel($id) { if (($model = Field::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested field does not exist.'); } }
public function search($params) { $query = Field::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => new \yii\data\Sort(['attributes' => ['name', 'type', 'relation_model', 'category_id']])]); $this->load($params); if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'type' => $this->type, 'category_id' => $this->category_id, 'relation_model' => $this->relation_model]); $query->andFilterWhere(['like', 'name', $this->name]); $query->andFilterWhere(['like', 'description', $this->description]); $query->andFilterWhere(['like', 'slug', $this->slug]); return $dataProvider; }
public function getFields() { $model = $this->owner; $fields = Field::find()->where(['relation_model' => $model::className()])->all(); return $fields; }
public function getFields() { return $this->hasMany(Field::className(), ['id' => 'field_id']); }
public static function saveEdit($id, $name, $value) { $setting = Field::findOne($id); $setting->{$name} = $value; $setting->save(); }