original_string: public function postUserRolePermissions(Request $request)
    {
      $this->validate($request, ['role' => 'required', 'permissions' => 'required']);
      $role = Role::with('permissions')->whereName($request->role)->first();
      $role->permissions()->detach();
      foreach ($request->permissions as $permission_name) {
        $permission = Permission::whereName($permission_name)->first();
        $role->assign($permission);
      }
      \Session::flash('flash_message', 'Permission granted!');
      return \Redirect::route('admin.assign-role-permissions',[
      ]);
    }
code: public function postUserRolePermissions(Request $request)
    {
      $this->validate($request, ['role' => 'required', 'permissions' => 'required']);
      $role = Role::with('permissions')->whereName($request->role)->first();
      $role->permissions()->detach();
      foreach ($request->permissions as $permission_name) {
        $permission = Permission::whereName($permission_name)->first();
        $role->assign($permission);
      }
      \Session::flash('flash_message', 'Permission granted!');
      return \Redirect::route('admin.assign-role-permissions',[
      ]);
    }
code_tokens: public function postUserRolePermissions ( Request $ request ) { $ this -> validate ( $ request , [ 'role' => 'required' , 'permissions' => 'required' ] ) ; $ role = Role :: with ( 'permissions' ) -> whereName ( $ request -> role ) -> first ( ) ; $ role -> permissions ( ) -> detach ( ) ; foreach ( $ request -> permissions as $ permission_name ) { $ permission = Permission :: whereName ( $ permission_name ) -> first ( ) ; $ role -> assign ( $ permission ) ; } \ Session :: flash ( 'flash_message' , 'Permission granted!' ) ; return \ Redirect :: route ( 'admin.assign-role-permissions' , [ ] ) ; }
docstring: Store given permissions to role.
  
  @param  \Illuminate\Http\Request  $request
  
  @return void
docstring_tokens: Store given permissions to role .