Esempio n. 1
0
 public function actionSearch()
 {
     $q = Yii::$app->getRequest()->getQueryParam('q');
     $query = Posts::find()->where(['hide' => 0])->where(['like', 'full_text', $q]);
     $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
     $posts = $query->offset($pagination->offset)->limit($pagination->limit)->all();
     Posts::setNumbers($posts);
     return $this->render('search', ['posts' => $posts, 'q' => $q, 'active_page' => Yii::$app->request->get("page", 1), 'count_pages' => $pagination->getPageCount(), 'pagination' => $pagination]);
 }