public function createPost(CreateCategoryRequest $request)
 {
     if ($request->isMethod('POST')) {
         $name = strip_tags($request->get('category_name'));
         $description = strip_tags($request->get('category_description'));
         $css = strip_tags($request->get('category_css'));
         $result = Category::create(['name' => $name, 'description' => $description, 'css_class' => $css]);
         if ($result !== null) {
             return redirect('/admin/categories')->with('status', Lang::get('messages.admin_categories_status_created'));
         }
     }
     return (new Response("Invalid Request", 400))->header('Content-Type', 'text/plain')->header("Pragma", "no-cache");
 }
 /**
  *
  * Create a new category
  *
  * @param CreateCategoryRequest $request
  * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
  */
 public function create(CreateCategoryRequest $request)
 {
     if ($request->ajax()) {
         $parent_id = $request->input('parent_id');
         $node = new Category($request->except(['parent_id']));
         if ($parent_id > 0) {
             $parent = Category::find($parent_id);
             $node->appendToNode($parent)->save();
         } else {
             $node->save();
             // Saved as root
         }
         return response()->json(['msg' => 'Категория добавлена', 'id' => $node->id]);
     }
     return redirect()->back() - with('msg', $this->no_js);
 }