Skip to content

Commit

Permalink
Fix phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 committed Jun 21, 2024
1 parent 41977f3 commit 1ec6982
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ parameters:
- database/migrations/add_teams_fields.php.stub
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkMissingIterableValueType: false

ignoreErrors:
-
identifier: missingType.iterableValue
- '#Unsafe usage of new static#'
# wildcard permissions:
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Model::getWildcardClass#'
Expand Down
10 changes: 6 additions & 4 deletions src/Traits/HasRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,14 @@ public function hasRole($roles, ?string $guard = null): bool

return $this->roles
->when($guard, fn ($q) => $q->where('guard_name', $guard))
->contains(function ($role) use ($roles) {
if ($role->name instanceof \BackedEnum) {
return $role->name->value == $roles;
->pluck('name')
->contains(function ($name) use ($roles) {
/** @var string|\BackedEnum $name */
if ($name instanceof \BackedEnum) {
return $name->value == $roles;
}

return $role->name == $roles;
return $name == $roles;
});
}

Expand Down

0 comments on commit 1ec6982

Please sign in to comment.