Example #1
0
 /**
  * @param $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     //$query = Setting::find();
     $query = Setting::find()->select('section, COUNT(*) as count')->distinct()->where('section is not null')->groupBy(['section']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     //        $query->andFilterWhere(
     //            [
     //                'id' => $this->id,
     //                'active' => $this->active,
     //                'section' => $this->section,
     //            ]
     //        );
     //
     //        $query->andFilterWhere(['like', 'key', $this->key])
     //            ->andFilterWhere(['like', 'value', $this->value]);
     //
     //        return $dataProvider;
 }
 /**
  * Finds a Setting model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Setting the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Setting::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }