novaspatiepermissions
novaspatiepermissions copied to clipboard
Permissions are not refreshed when adding a role to a permission
When adding a permission to a role it works fine, but when adding a role to a permission, the ForgetCachedPermissions listener does not fire.
The fix is to just check for the role class as well (in ForgetCachedPermissions)
$permissionKey = (Nova::resourceForModel(app(PermissionRegistrar::class)->getPermissionClass()))::uriKey();
$roleKey = (Nova::resourceForModel(app(PermissionRegistrar::class)->getRoleClass()))::uriKey();
if ($request->viaRelationship === $permissionKey || $request->viaRelationship === $roleKey) {
app(PermissionRegistrar::class)->forgetCachedPermissions();
}