public function update(UpdatePermissionRequest $request)
 {
     $permission = $this->permission->update($request->all());
     if ($permission->id) {
         flash()->success('更新成功');
     } else {
         flash()->error('更新失败');
     }
     return redirect()->back();
 }
Example #2
0
 public function update(\App\Http\Requests\UpdatePermissionRequest $request, $resource)
 {
     // get respective resource
     $permissions = $this->permission->getPermissionsByResourceName($resource);
     // update
     $this->permission->update($permissions, $request->all());
     // flash successfull message
     $request->session()->flash('success', 'Successfully update permission.');
     // redirect upon success
     return redirect()->route('admin.permission.edit', ['resource' => $resource]);
 }
 /**
  * Method for updating an existing permission with the given id in the database.
  *
  * @param $id
  * @param UpdatePermissionRequest $request
  * @return mixed
  */
 public function update($id, UpdatePermissionRequest $request)
 {
     $permission = Permission::find($id);
     $permission->update($request->all());
     if (is_null($request->get('roles'))) {
         $permission->roles()->sync([]);
     } else {
         $permission->roles()->sync($request->get('roles'));
     }
     $permission->routes()->delete();
     $routes = $request->get('routes');
     foreach ($routes as $route) {
         $permission->routes()->create(['route' => $route]);
     }
     return redirect(route('rbac.permissions.index'))->withSuccess('You have successfully updated a permission.');
 }
 public function update($id, UpdatePermissionRequest $request)
 {
     $permission = Permission::find($id);
     $permission->update($request->all());
     return redirect()->route('permissions.show', $id)->with('successes', ['Permission updated successfully']);
 }
 /**
  * Updates a user after passing UpdateUserRequest validation
  *
  * @param int                     $permission_id Permission ID
  * @param UpdatePermissionRequest $request       Handles permission validation
  *
  * @return Redirect
  */
 public function do_updatePermission($permission_id, UpdatePermissionRequest $request)
 {
     // Attempt to find the permission
     try {
         /** Permission $permission */
         $permission = Permission::findOrFail($permission_id);
         // IF an invalid permission ID was passed, throw a 404
     } catch (ModelNotFoundException $ex) {
         $this->_addDashboardMessage('The permission level you were looking for does not exist.', 'error');
         return redirect()->route('admin.listpermissions')->with('dashboardMessages', $this->dashboardMessages);
     }
     // Set values
     $permission->fill($request->all());
     // Save permission
     $permission->save();
     // Sync the permission role data
     $permissionRoleData = (array) $request->get('roles');
     $permission->syncRoles($permissionRoleData);
     // Add success message
     $this->_addDashboardMessage('Successfully updated the "' . $permission->label . '" permission level.', 'success');
     // Redirect the user to the edit page
     return redirect()->route('admin.editpermission', ['permission_id' => $permission->permission_id])->with('dashboardMessages', $this->dashboardMessages);
 }