diff --git a/src/Controllers/QuickadminMenuController.php b/src/Controllers/QuickadminMenuController.php index 370974d..cb59958 100644 --- a/src/Controllers/QuickadminMenuController.php +++ b/src/Controllers/QuickadminMenuController.php @@ -47,12 +47,9 @@ public function rearrange(Request $request) ->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(); + $menu->position = $request->{'menu-' . $menu->id}; + $menu->save(); + if (!$menu->children()->isEmpty()) { foreach ($menu->children as $child) { $child->position = $request->{'child-' . $child->id}; $child->parent_id = $request->{'child-parent-' . $child->id};