public function update(Request $request, $id)
 {
     $menu = Menu::findOrFail($id);
     $menu->update($request->all());
     return redirect()->route('menu');
 }
 public function update(Request $request, $id)
 {
     $roles = Role::all();
     $rolesInsert = '';
     $first = true;
     foreach ($roles as $role) {
         if ($request->{'role-' . $role->id} == 1) {
             if ($first != true) {
                 $rolesInsert .= ',';
             }
             $rolesInsert .= $role->id;
             $first = false;
         }
     }
     $requestArray = $request->all();
     if ($requestArray['parent_id'] === "null") {
         $requestArray['parent_id'] = null;
     }
     $requestArray['roles'] = $rolesInsert;
     $menu = Menu::findOrFail($id);
     $menu->update($requestArray);
     return redirect()->route('menu');
 }
 public function update(Request $request, $id)
 {
     $requestArray = $request->all();
     $requestArray['parent_id'] = isset($requestArray['parent_id']) && !empty($requestArray['parent_id']) ? $requestArray['parent_id'] : null;
     $menu = Menu::findOrFail($id);
     $menu->update($requestArray);
     $menu->roles()->sync($request->input('roles', []));
     return redirect()->route('menu');
 }