Skip to content

Commit

Permalink
Ensure $roles support
Browse files Browse the repository at this point in the history
\Illuminate\Contracts\Support\Arrayable|array|string.

Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed Apr 6, 2016
1 parent 5378f7c commit 92f9e3d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function detachRole($roles)
/**
* Determine if current user has the given role.
*
* @param string $roles
* @param \Illuminate\Contracts\Support\Arrayable|array|string $roles
*
* @return bool
*/
Expand Down Expand Up @@ -226,11 +226,11 @@ public function isActivated()
/**
* Determine if current user has any of the given role.
*
* @param array $roles
* @param \Illuminate\Contracts\Support\Arrayable|array|string $roles
*
* @return bool
*/
public function isAny(array $roles)
public function isAny($roles)
{
$userRoles = $this->getRoles();

Expand All @@ -246,7 +246,7 @@ public function isAny(array $roles)

// We should ensure that any given roles match the current user,
// consider it as OR condition.
foreach ($roles as $role) {
foreach ((array) $roles as $role) {
if (in_array($role, $userRoles)) {
return true;
}
Expand All @@ -258,7 +258,7 @@ public function isAny(array $roles)
/**
* Determine if current user does not has any of the given role.
*
* @param string $roles
* @param \Illuminate\Contracts\Support\Arrayable|array|string $roles
*
* @return bool
*/
Expand All @@ -270,11 +270,11 @@ public function isNot($roles)
/**
* Determine if current user does not has any of the given role.
*
* @param array $roles
* @param \Illuminate\Contracts\Support\Arrayable|array|string $roles
*
* @return bool
*/
public function isNotAny(array $roles)
public function isNotAny($roles)
{
return ! $this->isAny($roles);
}
Expand Down

0 comments on commit 92f9e3d

Please sign in to comment.