/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, UpdateRoleRequest $request) { $name = $request->get('name'); $count = Role::whereName($name)->where('id', '!=', $id)->count(); if ($count > 0) { return $this->redirectWithError('角色名称不能重复'); } $data = $request->only('name'); Role::findOrFail($id)->update($data); return redirect()->route('admin.roles.index'); }