Ejemplo n.º 1
0
 public function actionResult()
 {
     $model = new Search();
     if ($model->load(Yii::$app->request->get()) && $model->validate()) {
         $query = $model->extendSearch();
         if (!$query) {
             Yii::$app->session->setFlash('error', 'Ошибка при валидации');
             Yii::error('Ошибка при валидации');
             return $this->goHome();
         }
         $pagination = new Pagination(['defaultPageSize' => 3, 'totalCount' => $query->count()]);
         $tours = $query->offset($pagination->offset)->limit($pagination->limit)->all();
         return $this->render('result', ['tours' => $tours, 'pagination' => $pagination, 'model' => $model]);
     }
     $this->redirect('extendsearch', 302);
 }