src/Http/Controllers/Admin/AdminController.php
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',[
    ]);
  }
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',[
    ]);
  }
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' , [ ] ) ; }
Store given permissions to role.

@param  \Illuminate\Http\Request  $request

@return void
Store given permissions to role .