Skip to content

Commit

Permalink
Merge pull request #1 from spatie/main
Browse files Browse the repository at this point in the history
updates from main
  • Loading branch information
crossplatformconsulting authored Nov 5, 2024
2 parents 19bf7ab + 8efe3d4 commit fc3f68b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/PermissionRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private function loadPermissions(): void
$this->cacheKey, $this->cacheExpirationTime, fn () => $this->getSerializedPermissionsForCache()
);

// fallback for old cache method, must be removed on next mayor version
// fallback for old cache method, must be removed on next major version
if (! isset($this->permissions['alias'])) {
$this->forgetCachedPermissions();
$this->loadPermissions();
Expand Down Expand Up @@ -360,7 +360,7 @@ private function getHydratedPermissionCollection(): Collection
$permissionInstance = new ($this->getPermissionClass())();

return Collection::make(array_map(
fn ($item) => $permissionInstance->newInstance([], true)
fn ($item) => (clone $permissionInstance)
->setRawAttributes($this->aliasedArray(array_diff_key($item, ['r' => 0])), true)
->setRelation('roles', $this->getHydratedRoleCollection($item['r'] ?? [])),
$this->permissions['permissions']
Expand All @@ -379,7 +379,7 @@ private function hydrateRolesCache(): void
$roleInstance = new ($this->getRoleClass())();

array_map(function ($item) use ($roleInstance) {
$role = $roleInstance->newInstance([], true)
$role = (clone $roleInstance)
->setRawAttributes($this->aliasedArray($item), true);
$this->cachedRoles[$role->getKey()] = $role;
}, $this->permissions['roles']);
Expand Down

0 comments on commit fc3f68b

Please sign in to comment.