Http/Controllers/Admin/CategoryController.php
public function updateOrder(Request $request): JsonResponse
    {
        Category::rebuildTree(
            $request->input('tree')
        );

        $this->clearCache();

        $movedNode = Category::findOrFail(
            $request->input('moved')
        );

        dispatch(
            new RegenerateCategoryFullSlugs($movedNode)
        );

        return response()->json([
            'state' => 'success',
        ]);
    }
public function updateOrder(Request $request): JsonResponse
    {
        Category::rebuildTree(
            $request->input('tree')
        );

        $this->clearCache();

        $movedNode = Category::findOrFail(
            $request->input('moved')
        );

        dispatch(
            new RegenerateCategoryFullSlugs($movedNode)
        );

        return response()->json([
            'state' => 'success',
        ]);
    }
public function updateOrder ( Request $ request ) : JsonResponse { Category :: rebuildTree ( $ request -> input ( 'tree' ) ) ; $ this -> clearCache ( ) ; $ movedNode = Category :: findOrFail ( $ request -> input ( 'moved' ) ) ; dispatch ( new RegenerateCategoryFullSlugs ( $ movedNode ) ) ; return response ( ) -> json ( [ 'state' => 'success' , ] ) ; }
Rebuild categories tree.

@param \Illuminate\Http\Request $request
@return \Illuminate\Http\JsonResponse
Rebuild categories tree .