protected function getModelsByField($field) { if (!isset(static::$models[$field])) { static::$models[$field] = Lookup::find()->where(['table' => $this->tableName(), 'field' => $field])->orderBy(['position' => SORT_ASC, 'name' => SORT_ASC])->all(); } return static::$models[$field]; }
private static function loadItems($type) { self::$_items[$type] = array(); $models = Lookup::find()->where(['type' => $type])->orderBy('position')->all(); foreach ($models as $model) { self::$_items[$type][$model->code] = $model->name; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Lookup::find()->with(['creater', 'updater', 'deleter'])->asArray(true); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['label' => SORT_ASC]]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['enabled' => $this->enabled]); $query->andFilterWhere(['like', 'label', $this->label])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'return_type', $this->return_type]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Lookup::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'code' => $this->code, 'position' => $this->position]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'type', $this->type]); return $dataProvider; }
public function search($params) { $query = Lookup::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $this->addCondition($query, 'id'); $this->addCondition($query, 'name', true); $this->addCondition($query, 'code'); $this->addCondition($query, 'type', true); $this->addCondition($query, 'position'); return $dataProvider; }
/** * Finds the Lookup model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Lookup the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { $model = Lookup::find()->where(['id' => (int) $id])->one(); if ($model !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }