Skip to content

Commit 6c2421c

Browse files
committedJan 10, 2016
fix for testing non existing permissions
1 parent cb6ac82 commit 6c2421c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
 

‎CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

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

5+
## 1.3.1 - 2016-01-10
6+
7+
- fixed bug when testing for non existing permissions
8+
59
## 1.3.0 - 2015-12-25
610

711
- added compatiblity for Laravel 5.2

‎src/Traits/HasRoles.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function hasRole($roles)
7777
return $this->roles->contains('id', $roles->id);
7878
}
7979

80-
return (bool) !!$roles->intersect($this->roles)->count();
80+
return (bool) (bool) $roles->intersect($this->roles)->count();
8181
}
8282

8383
/**
@@ -169,6 +169,10 @@ protected function hasDirectPermission(Permission $permission)
169169
{
170170
if (is_string($permission)) {
171171
$permission = app(Permission::class)->findByName($permission);
172+
173+
if (!$permission) {
174+
return false;
175+
}
172176
}
173177

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

0 commit comments

Comments
 (0)