/** * Lists all Menu models. * @return mixed */ public function actionIndex() { $model = new Search(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { $list = Page::find()->filterWhere(['like', 'text', $model['search']])->all(); if (count($list) == 0) { $errors = 'По Вашему запросу ничего не найдено. Попробуйте задать другой запрос.'; return $this->render('index', ['search' => $model['search'], 'errors' => $errors]); } else { return $this->render('index', ['search' => $model['search'], 'list' => $list]); } } }
public function actionSearch() { $model = new Search(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { $result = $model->getBySearch($model); if (!$result) { Yii::$app->session->setFlash('error', 'Nothing was found.'); } //User::d($result); /*$countQuery = clone $result; $pages = new Pagination(['totalCount' => $countQuery->count(),'defaultPageSize'=>20]); $models = $result->offset($pages->offset) ->limit($pages->limit) ->all(); if(!isset($sort)){ $sort = 1; }*/ return $this->render('search', ['models' => $result, 'lang' => $this->lang]); } }