示例#1
0
 public function _assignToDefault($categoryId)
 {
     $defaultCategory = FaqCategory::getDefault($this->getAccountId());
     $condition = ['isDeleted' => false, 'faqCategoryId' => $categoryId];
     $results = Faq::find()->where($condition)->all();
     foreach ($results as $result) {
         $result['faqCategoryId'] = $defaultCategory->_id . '';
         $result->save();
     }
 }
示例#2
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];
 }
示例#3
0
 public function getQuestions()
 {
     $condition = ['isDeleted' => false, 'accountId' => $this->accountId, 'faqCategoryId' => $this->_id . ''];
     return Faq::find()->where($condition)->orderBy(['createdAt' => SORT_DESC])->all();
 }