/**
  * Store given permissions to role.
  *
  * @param  \Illuminate\Http\Request  $request
  *
  * @return void
  */
 public function postGiveRolePermissions(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->givePermissionTo($permission);
     }
     Session::flash('flash_message', 'Permission granted!');
     return redirect('admin/roles');
 }
 protected function getPermissions()
 {
     return Permission::with('roles')->get();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     Permission::destroy($id);
     Session::flash('flash_message', 'Permission deleted!');
     return redirect('admin/permissions');
 }