/** * Lists all User models. * @return mixed */ public function actionIndex() { $params = Yii::$app->request->queryParams; $params = Utils::rememberSearchModel($params, 'UserSearch'); $searchModel = new UserSearch(); $dataProvider = $searchModel->search($params); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'cities' => $this->getCitiesView(), 'educations' => $this->getEducationsView()]); }
/** * Lists all Book models. * @return mixed */ public function actionIndex() { $params = Yii::$app->request->queryParams; $params = Utils::rememberSearchModel($params, 'BookSearch'); $searchModel = new BookSearch(); $dataProvider = $searchModel->search($params); $authors = $this->getAuthors(); return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'authors' => $authors]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = User::find()->select('user.*')->joinWith('education'); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => self::PAGE_SIZE], 'sort' => ['attributes' => ['username', 'email']]]); $this->load($params); if (!$this->validate()) { return $dataProvider; } $className = UserSearch::className(); if (isset($params[Utils::getClassName($className)]['cities']) && $params[Utils::getClassName($className)]['cities']) { $cityIds = $params[Utils::getClassName($className)]['cities']; $query->joinWith('cities')->where(['cities.id' => $cityIds])->distinct('user.username'); } if (isset($this->education_id) && $this->education_id) { $query->andFilterWhere(['education_id' => $this->education_id]); } $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }
/** * Получение картинки * @return string */ public function getImage() { $result = Utils::getImagePath() . $this->preview; return $result; }