/** * Update the role. * * @param Role $role Role * * @return \Illuminate\Http\RedirectResponse */ public function update(Role $role) { $this->validate(request(), ['name' => ['required', Rule::unique('roles')->ignore($role->id)], 'label' => 'required', 'sort_order' => 'required|integer']); if (request()->ajax()) { return ajaxSuccess(); } if ($role->update(['name' => snake_slug(request()->name), 'label' => ucfirst(request()->label), 'sort_order' => request()->sort_order, 'is_admin' => isset(request()->is_admin)])) { flash()->success(trans('admin::messages.success'), trans('admin::roles.updated', ['name' => request()->name])); } return redirect()->back(); }
/** * Update the menu. * * @param Menu $menu Menu type * * @return \Illuminate\Http\RedirectResponse */ public function update(Menu $menu) { $this->validate(request(), ['code' => ['required', Rule::unique('menus')->ignore($menu->id)], 'title' => 'required', 'sort_order' => 'required|integer']); if (request()->ajax()) { return ajaxSuccess(); } if ($menu->update(['code' => snake_slug(request()->code), 'title' => ucfirst(request()->title), 'sort_order' => request()->sort_order])) { flash()->success(trans('admin::messages.success'), trans('admin::menus.updated', ['name' => request()->title])); } return redirect()->route('menus.index'); }
/** * Update the permission. * * @param Permission $permission Permission * * @return \Illuminate\Http\RedirectResponse */ public function update(Permission $permission) { $this->validate(request(), ['name' => ['required', Rule::unique('permissions')->ignore($permission->id)], 'label' => 'required', 'sort_order' => 'required|integer']); if (request()->ajax()) { return ajaxSuccess(); } if ($permission->update(['name' => snake_slug(request()->name), 'label' => ucfirst(request()->label), 'sort_order' => request()->sort_order])) { flash()->success(trans('admin::messages.success'), trans('admin::permissions.updated', ['name' => request()->name])); } return redirect()->route('permissions.index'); }