Skip to content

Commit

Permalink
fix role attach
Browse files Browse the repository at this point in the history
  • Loading branch information
afshinyahyayi committed Feb 16, 2018
1 parent 4042ac4 commit 8706575
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/Controller/Admin/User/UserController.php
Expand Up @@ -155,11 +155,14 @@ public function put_update_Action(Request $request, Response $response, $args)
UserDataAccess::updateuserFieldById($user,$fields);
$newRoles = (trim(str_replace('0','',trim($params['roles'],',')),','));
$attachedRoles = explode(',', $newRoles);
// $attachRolesToUsers =
if($attachedRoles){
$user->roles()->sync($attachedRoles);
$user->save();

if(count($attachedRoles) == 1 && $attachedRoles[0] == ''){
unset($attachedRoles[0]);
$attachedRoles = [];
}
// $attachRolesToUsers =
$user->roles()->sync($attachedRoles);
$user->save();

$uploadedFiles = $request->getUploadedFiles();
if($uploadedFiles){
Expand Down

0 comments on commit 8706575

Please sign in to comment.