Skip to content

Commit

Permalink
Avoid triggering eloquent.retrieved event (#2490)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 authored Aug 30, 2023
1 parent 069b2c0 commit b84f550
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/PermissionRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ private function getHydratedPermissionCollection()

return Collection::make(
array_map(function ($item) use ($permissionInstance) {
return $permissionInstance
->newFromBuilder($this->aliasedArray(array_diff_key($item, ['r' => 0])))
return $permissionInstance->newInstance([], true)
->setRawAttributes($this->aliasedArray(array_diff_key($item, ['r' => 0])), true)
->setRelation('roles', $this->getHydratedRoleCollection($item['r'] ?? []));
}, $this->permissions['permissions'])
);
Expand All @@ -364,7 +364,8 @@ private function hydrateRolesCache()
$roleInstance = new $roleClass();

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

Expand Down

0 comments on commit b84f550

Please sign in to comment.