Skip to content

Commit

Permalink
fix for testing non existing permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Jan 10, 2016
1 parent cb6ac82 commit 6c2421c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All Notable changes to `laravel-permission` will be documented in this file

## 1.3.1 - 2016-01-10

- fixed bug when testing for non existing permissions

## 1.3.0 - 2015-12-25

- added compatiblity for Laravel 5.2
Expand Down
6 changes: 5 additions & 1 deletion src/Traits/HasRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function hasRole($roles)
return $this->roles->contains('id', $roles->id);
}

return (bool) !!$roles->intersect($this->roles)->count();
return (bool) (bool) $roles->intersect($this->roles)->count();
}

/**
Expand Down Expand Up @@ -169,6 +169,10 @@ protected function hasDirectPermission(Permission $permission)
{
if (is_string($permission)) {
$permission = app(Permission::class)->findByName($permission);

if (!$permission) {
return false;
}
}

return $this->permissions->contains('id', $permission->id);
Expand Down

0 comments on commit 6c2421c

Please sign in to comment.