protected function findModel($id) { if (($model = ApplicationConfig::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ApplicationConfig::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, 'visitors_count' => $this->visitors_count]); $query->andFilterWhere(['like', 'slider_img1', $this->slider_img1])->andFilterWhere(['like', 'slider_img2', $this->slider_img2])->andFilterWhere(['like', 'slider_img3', $this->slider_img3]); return $dataProvider; }
public function actionIndex() { $visitor = ApplicationConfig::findOne(1); return $this->render('index', ['visitor' => $visitor]); }