Example #1
0
 protected function findModel($id)
 {
     if (($model = Field::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested field does not exist.');
     }
 }
Example #2
0
 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;
 }
Example #3
0
 public function getFields()
 {
     $model = $this->owner;
     $fields = Field::find()->where(['relation_model' => $model::className()])->all();
     return $fields;
 }