src/Modules/Roles/Services/RoleService.php 1 location
|
@@ 26-36 (lines=11) @@
|
| 23 |
|
* @param array $permissionIds |
| 24 |
|
* @return object |
| 25 |
|
*/ |
| 26 |
|
public function assignPermissions($roleId, $permissionIds) |
| 27 |
|
{ |
| 28 |
|
$role = false; |
| 29 |
|
\DB::transaction(function () use ($roleId, $permissionIds, &$role) { |
| 30 |
|
$role = $this->repo->find($roleId); |
| 31 |
|
$this->repo->detachPermissions($roleId); |
| 32 |
|
$this->repo->attachPermissions($roleId, $permissionIds); |
| 33 |
|
}); |
| 34 |
|
|
| 35 |
|
return $role; |
| 36 |
|
} |
| 37 |
|
} |
| 38 |
|
|
src/Modules/Users/Services/UserService.php 1 location
|
@@ 137-147 (lines=11) @@
|
| 134 |
|
* @param array $roleIds |
| 135 |
|
* @return object |
| 136 |
|
*/ |
| 137 |
|
public function assignRoles($userId, $roleIds) |
| 138 |
|
{ |
| 139 |
|
$user = false; |
| 140 |
|
\DB::transaction(function () use ($userId, $permissionIds, &$user) { |
| 141 |
|
$user = $this->repo->find($userId); |
| 142 |
|
$this->repo->detachPermissions($userId); |
| 143 |
|
$this->repo->attachPermissions($userId, $roleIds); |
| 144 |
|
}); |
| 145 |
|
|
| 146 |
|
return $user; |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
/** |
| 150 |
|
* Handle a login request to the application. |