/**
  * @param CategoryRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(CategoryRequest $request)
 {
     $parent_id = $request->get('parent_id', null) == '' ? null : $request->get('parent_id', null);
     if (is_null($parent_id)) {
         $this->category->save($request->all(), null);
         return redirect()->route('category.show', null)->with('success', 'Category saved successfully.');
     }
     if ($category = $this->category->save($request->all(), $parent_id)) {
         $parent = $this->category->find($parent_id);
         $root = $parent->getRoot();
         $parent_id = $root->id;
         $active_id = $category->id;
         if ($category->getDepth() > 1) {
             $active_id = $category->parent_id;
         }
         return redirect()->route('category.show', [$parent_id, 'active_tab' => $active_id])->with('success', 'Category saved successfully.');
     }
     return redirect()->route('category')->with('error', 'There is some problem saving category.');
 }