app/Http/Controllers/NestedSetController.php
public function store(CategoryRequest $request, $id = null)
    {
        $category = $this->repository->create($request, $id);

        if ($category) {
            $message = "Successfully created $this->resource";

            return redirect()->route($this->routes['index'])->withSuccess($message);
        } else {
            $message = "There was an issue creating a $this->resource. Please try again.";

            return redirect()->route($this->routes['create'], $id)->withErrors($message);
        }
    }
public function store(CategoryRequest $request, $id = null)
    {
        $category = $this->repository->create($request, $id);

        if ($category) {
            $message = "Successfully created $this->resource";

            return redirect()->route($this->routes['index'])->withSuccess($message);
        } else {
            $message = "There was an issue creating a $this->resource. Please try again.";

            return redirect()->route($this->routes['create'], $id)->withErrors($message);
        }
    }
Processes storing a new category or storing a new category
underneath another if an ID is specified.

@param CategoryRequest $request
@param int|string      $id

@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse