Skip to content

Commit 304795a

Browse files
authored
Merge pull request #1178 from christianberkman/move-matrix
refactor: [Authorizable Trait] move $matrix outside foreach loop
2 parents 60f1ae3 + c0268d9 commit 304795a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Authorization/Traits/Authorizable.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ public function can(string ...$permissions): bool
250250
// Check the groups the user belongs to
251251
$this->populateGroups();
252252

253+
// Get the group matrix
254+
$matrix = setting('AuthGroups.matrix');
255+
253256
foreach ($permissions as $permission) {
254257
// Permission must contain a scope and action
255258
if (strpos($permission, '.') === false) {
@@ -270,8 +273,6 @@ public function can(string ...$permissions): bool
270273
return false;
271274
}
272275

273-
$matrix = setting('AuthGroups.matrix');
274-
275276
foreach ($this->groupCache as $group) {
276277
// Check exact match
277278
if (isset($matrix[$group]) && in_array($permission, $matrix[$group], true)) {

0 commit comments

Comments
 (0)