/**
  * Create a new user instance after a valid registration.
  *
  * @param integer $id
  * @param  array $data
  * @return User
  */
 public function update($id, array $data)
 {
     $user = User::findOrFail($id);
     if (array_key_exists('password', $data) and empty($data['password'])) {
         unset($data['password']);
     }
     $user->update(array_only($data, ['username', 'password', 'email', 'locale']));
     if (isset($data['user_roles'])) {
         $roles = $data['user_roles'];
         if (!is_array($roles)) {
             $roles = explode(',', $roles);
         }
         $user->roles()->sync($roles);
     }
     return $user;
 }
 public function getRoles()
 {
     $userId = $this->getParameter('uid');
     $this->setContent(User::findOrFail($userId)->roles()->get());
 }
 /**
  * @param integer|null $id
  * @return User
  * @throws HttpResponseException
  */
 protected function getUser($id = NULL)
 {
     if (is_null($id)) {
         return $this->currentUser;
     }
     try {
         return User::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         $this->throwFailException($this->smartRedirect()->withErrors(trans('users::core.messages.user.not_found')));
     }
 }