示例#1
0
 public static function getAllSettings()
 {
     $results = Setting::find();
     /*$pagination = new Pagination(['defaultPageSize'=>DEFAULT_PAGE_SIZE, 'totalCount'=> $results->count()]);*/
     $settings = [];
     $results = $results->orderBy('id')->asArray()->all();
     foreach ($results as $result) {
         $settings[$result['name']]['value'] = $result['value'];
     }
     return $settings;
 }
 public function actionIndex($count = DEFAULT_PAGE_SIZE)
 {
     if (Yii::$app->request->isAjax) {
         Yii::$app->controller->module->layout = false;
     }
     $where_clause = null;
     if (isset(\Yii::$app->controller->searchFields)) {
         $argument_data = null;
         if (Yii::$app->request->isAjax) {
             $argument_data = $_REQUEST;
         }
         $where_clause = \vendor\codefire\cfusermgmt\models\Behavior\searchBehavior::search_behavior($argument_data);
     }
     $query = Setting::find()->where($where_clause);
     $activeDataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $count], 'sort' => ['defaultOrder' => ['id' => SORT_DESC], 'attributes' => ['created', 'id', 'name_public', 'value']]]);
     //  echo "<pre>";print_r($query);die;
     $models = $activeDataProvider->getModels();
     return $this->render('index', ['activeDataProvider' => $activeDataProvider, 'models' => $models]);
 }