Skip to content

Commit

Permalink
Add wildcard check for hasRole and hasPermission methods
Browse files Browse the repository at this point in the history
  • Loading branch information
romanbican committed Jun 16, 2015
1 parent febb1ed commit b2b09c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Bican/Roles/Traits/HasRoleAndPermission.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ protected function isAll(array $roles)
*/
protected function hasRole($role)
{
return $this->getRoles()->contains($role) || $this->getRoles()->contains('slug', $role);
return $this->getRoles()->contains(function ($key, $value) use ($role) {
return $role == $value->id || str_is($role, $value->slug);
});
}

/**
Expand Down Expand Up @@ -225,7 +227,9 @@ protected function canAll(array $permissions)
*/
protected function hasPermission($permission)
{
return $this->getPermissions()->contains($permission) || $this->getPermissions()->contains('slug', $permission);
return $this->getPermissions()->contains(function ($key, $value) use ($permission) {
return $permission == $value->id || str_is($permission, $value->slug);
});
}

/**
Expand Down

0 comments on commit b2b09c6

Please sign in to comment.