Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Pathologic authored Sep 24, 2023
1 parent f181671 commit caf21cd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Services/Users/UserEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ public function process(): \Illuminate\Database\Eloquent\Model
if (!$this->checkRules()) {
throw new ServiceActionException(\Lang::get('global.error_no_privileges'));
}


$user = User::find($this->userData['id']);
$this->userData = array_merge($user->toArray() + $user->attributes->toArray(), $this->userData);

// invoke OnBeforeUserFormSave event
if ($this->events) {
EvolutionCMS()->invokeEvent("OnBeforeUserSave", [
Expand All @@ -116,7 +119,7 @@ public function process(): \Illuminate\Database\Eloquent\Model
$exception->setValidationErrors($this->validateErrors);
throw $exception;
}
$user = User::find($this->userData['id']);

if (isset($this->userData['username']) && $this->userData['username'] != '') {
$user->username = $this->userData['username'];
$user->save();
Expand Down

0 comments on commit caf21cd

Please sign in to comment.