Пример #1
0
 /**
  * @param GetIndexDataRequest $request
  * @return mixed
  */
 public function get(GetIndexDataRequest $request)
 {
     $response = new AjaxResponse();
     $response->setSuccessMessage(trans('common.success'));
     $response->addExtraFields(['categories' => HelpCenterManagerHelper::getHelpCenterCategoriesAndArticles()]);
     return response($response->get())->header('Content-Type', 'application/json');
 }
Пример #2
0
 /**
  * Edit article title and content.
  *
  * @param int $categoryId
  * @param EditArticleRequest $request
  * @return mixed
  */
 public function editArticle($categoryId, EditArticleRequest $request)
 {
     $response = new AjaxResponse();
     $category = HelpCenterCategory::where('id', $categoryId)->first();
     if (!$category) {
         $response->setFailMessage(trans('help_center.category_not_found'));
         return response($response->get(), $response->getDefaultErrorResponseCode())->header('Content-Type', 'application/json');
     }
     // Edit article
     $article = HelpCenterArticle::find($request->get('article_id'));
     $article->title = $request->get('article_title');
     $article->content = $request->get('article_content');
     $article->save();
     // Get updated version of articles
     $extraFields = [];
     $articles = HelpCenterManagerHelper::getCategoryArticles($categoryId);
     if (count($articles)) {
         $extraFields['articles'] = $articles;
     }
     $response->setSuccessMessage(trans('help_center.article_updated'));
     $response->addExtraFields($extraFields);
     return response($response->get())->header('Content-Type', 'application/json');
 }