Skip to content

Commit

Permalink
Merge pull request #2411 from erikn69/patch-24
Browse files Browse the repository at this point in the history
Fix call to an undefined method Role::getRoleClass
  • Loading branch information
drbyte committed Apr 26, 2023
2 parents a2ad839 + d595dff commit 9e9190a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
parameters:
ignoreErrors:
-
# PHPStan can't understand what's going on in context of Role class using Builder `when`
message: "#^Call to an undefined method Spatie\\\\Permission\\\\Models\\\\Role::getRoleClass\\(\\).$#"
count: 1
path: src\Traits\HasPermissions.php
2 changes: 1 addition & 1 deletion src/Traits/HasPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function scopePermission(Builder $query, $permissions): Builder

$permissionClass = $this->getPermissionClass();
$permissionKey = (new $permissionClass())->getKeyName();
$roleClass = $this->getRoleClass();
$roleClass = is_a($this, Role::class) ? static::class : $this->getRoleClass();
$roleKey = (new $roleClass())->getKeyName();

$rolesWithPermissions = is_a($this, Role::class) ? [] : array_unique(
Expand Down

0 comments on commit 9e9190a

Please sign in to comment.