Example #1
0
 /**
  * Update the category.
  *
  * @param Request $request
  * @param Model   $category
  *
  * @return Response
  */
 public function update(CategoryAdminRequest $request, Category $category)
 {
     try {
         $attributes = $request->all();
         $category->update($attributes);
         return response()->json(['message' => trans('messages.success.updated', ['Module' => trans('faq::category.name')]), 'code' => 204, 'redirect' => trans_url('/admin/faq/category/' . $category->getRouteKey())], 201);
     } catch (Exception $e) {
         return response()->json(['message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/faq/category/' . $category->getRouteKey())], 400);
     }
 }
 /**
  * Update the category.
  *
  * @param Request $request
  * @param Model   $category
  *
  * @return json
  */
 public function update(CategoryUserApiRequest $request, Category $category)
 {
     try {
         $attributes = $request->all();
         $category->update($attributes);
         $category = $category->presenter();
         $category['code'] = 2005;
         return response()->json($category)->setStatusCode(201, 'UPDATE_SUCCESS');
     } catch (Exception $e) {
         return response()->json(['message' => $e->getMessage(), 'code' => 4005])->setStatusCode(400, 'UPDATE_ERROR');
     }
 }