src/Controllers/QuickadminMenuController.php
public function rearrange(Request $request)
    {
        $menusList = Menu::with(['children'])
            ->where('menu_type', '!=', 0)
            ->where('parent_id', null)
            ->orderBy('position')->get();
        foreach ($menusList as $menu) {
            if ($menu->children()->first() == null) {
                $menu->position = $request->{'menu-' . $menu->id};
                $menu->save();
            } else {
                $menu->position = $request->{'menu-' . $menu->id};
                $menu->save();
                foreach ($menu->children as $child) {
                    $child->position  = $request->{'child-' . $child->id};
                    $child->parent_id = $request->{'child-parent-' . $child->id};
                    $child->save();
                }
            }
        }

        return redirect()->back();
    }
public function rearrange(Request $request)
    {
        $menusList = Menu::with(['children'])
            ->where('menu_type', '!=', 0)
            ->where('parent_id', null)
            ->orderBy('position')->get();
        foreach ($menusList as $menu) {
            if ($menu->children()->first() == null) {
                $menu->position = $request->{'menu-' . $menu->id};
                $menu->save();
            } else {
                $menu->position = $request->{'menu-' . $menu->id};
                $menu->save();
                foreach ($menu->children as $child) {
                    $child->position  = $request->{'child-' . $child->id};
                    $child->parent_id = $request->{'child-parent-' . $child->id};
                    $child->save();
                }
            }
        }

        return redirect()->back();
    }
public function rearrange ( Request $ request ) { $ menusList = Menu :: with ( [ 'children' ] ) -> where ( 'menu_type' , '!=' , 0 ) -> where ( 'parent_id' , null ) -> orderBy ( 'position' ) -> get ( ) ; foreach ( $ menusList as $ menu ) { if ( $ menu -> children ( ) -> first ( ) == null ) { $ menu -> position = $ request -> { 'menu-' . $ menu -> id } ; $ menu -> save ( ) ; } else { $ menu -> position = $ request -> { 'menu-' . $ menu -> id } ; $ menu -> save ( ) ; foreach ( $ menu -> children as $ child ) { $ child -> position = $ request -> { 'child-' . $ child -> id } ; $ child -> parent_id = $ request -> { 'child-parent-' . $ child -> id } ; $ child -> save ( ) ; } } } return redirect ( ) -> back ( ) ; }
Rearrange quickadmin menu items

@param Request $request

@return \Illuminate\Http\RedirectResponse
Rearrange quickadmin menu items