Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Commit

Permalink
use of not created ability will return false instead of exception
Browse files Browse the repository at this point in the history
  • Loading branch information
thekordy committed Jan 19, 2017
1 parent bf9ff53 commit 5b772d3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Traits/RoleTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,16 @@ public function hasPermissionTo($ability)
public function permissionTo($ability)
{
$ability = AuzoAbility::findByNameOrId($ability);
foreach ($ability->permissions as $permission) {
if ($permission->role_id === $this->id) {
return $permission;

if ($ability) {
foreach ($ability->permissions as $permission) {
if ($permission->role_id === $this->id) {
return $permission;
}
}
}

return false;
// return $this->permissions()->forAbility($ability);
}

/**
Expand Down

0 comments on commit 5b772d3

Please sign in to comment.