Skip to content

Commit

Permalink
Give & Drop role methods now also accept arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
RamonSmit authored Dec 12, 2019
1 parent ce7463c commit df6ec35
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Traits/Permissible.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,37 @@ public function hasPermission($name)
/**
* Assign role to user
*
* @param string $name Name of the role
* @param string|array $name Name of the role
*
* @return object $this instance of model
*/
public function giveRole($name)
{
if (is_array($name)) {
foreach ($name as $k => $item) {
return Permission::linkUserToRole($this, $item);
}
}

return Permission::linkUserToRole($this, $name);
}

/**
* Drop role from user
*
* @param string $name Name of the role
* @param string|array $name Name of the role
*
* @return object $this instance of model
*/
public function dropRole($name)
{
if (is_array($name))
{
foreach ($name as $k => $item) {
return Permission::takeRoleFromUser($this, $item);
}
}

return Permission::takeRoleFromUser($this, $name);
}

Expand Down

0 comments on commit df6ec35

Please sign in to comment.