Exemplo n.º 1
0
 public function actionIndex()
 {
     $accountId = $this->getAccountId();
     $params = $this->getQuery();
     $condition = ['accountId' => $accountId, 'isDeleted' => Faq::NOT_DELETED];
     if (!empty($params['faqCategoryId'])) {
         $condition['faqCategoryId'] = $params['faqCategoryId'];
     }
     $totalCount = Faq::count($condition);
     $currentPage = $params['page'];
     $perPage = $params['per-page'];
     $offset = ($currentPage - 1) * $perPage;
     $pageCount = (int) (($totalCount - 1) / $perPage + 1);
     $faqs = Faq::search($condition, $offset, $perPage);
     return ['totalCount' => $totalCount, 'currentPage' => $currentPage, 'perPage' => $perPage, 'pageCount' => $pageCount, 'faqs' => $faqs];
 }