public function searchByTYpe($type) { $query = Parameter::find(); $query->where('type = :type', [':type' => $type]); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status' => $type, 'sort' => $this->sort]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'type', $type]); return $dataProvider; }
/** * Finds the Parameter model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Parameter the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Parameter::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }