Skip to content

Commit 0d9c442

Browse files
authored
Merge pull request spatie#1058 from spatie/revert-1054-performance-fix
Revert spatie#1054 "[Performance] avoid to iterate the list twice and returns on first found permission"
2 parents 386b13e + e517598 commit 0d9c442

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/PermissionRegistrar.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,11 @@ public function getPermissions(array $params = []): Collection
137137

138138
$permissions = clone $this->permissions;
139139

140-
return collect([$permissions->first(function ($item) use ($params) {
141-
foreach ($params as $key => $value) {
142-
if ($item[$key] !== $value) {
143-
return false;
144-
}
145-
}
140+
foreach ($params as $attr => $value) {
141+
$permissions = $permissions->where($attr, $value);
142+
}
146143

147-
return true;
148-
})]);
144+
return $permissions;
149145
}
150146

151147
/**

0 commit comments

Comments
 (0)