diff --git a/app/Models/Agent.php b/app/Models/Agent.php index 74af22c..02207b1 100644 --- a/app/Models/Agent.php +++ b/app/Models/Agent.php @@ -33,13 +33,13 @@ class Agent extends BaseModel public function setPasswordAttribute($value) { - //新增时 - if ($value && empty($this->attributes['password'])) { - $this->attributes['password'] = $this->passMd5($value); - } - //编辑时 - else if ($value && !empty($this->attributes['password']) && $this->attributes['password'] != $value) { - $this->attributes['password'] = $this->passMd5($value); + if ($value) { + if ( + empty($this->attributes['password']) || //新增时 + $this->attributes['password'] != $value && !empty($this->attributes['password']) //编辑时 + ) { + $this->attributes['password'] = $this->passMd5($value); + } } } diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php index c31015c..73faf15 100644 --- a/app/Models/Supplier.php +++ b/app/Models/Supplier.php @@ -21,13 +21,13 @@ class Supplier extends BaseModel public function setPasswordAttribute($value) { - //新增时 - if ($value && empty($this->attributes['password'])) { - $this->attributes['password'] = $this->passMd5($value); - } - //编辑时 - else if ($value && !empty($this->attributes['password']) && $this->attributes['password'] != $value) { - $this->attributes['password'] = $this->passMd5($value); + if ($value) { + if ( + empty($this->attributes['password']) || //新增时 + $this->attributes['password'] != $value && !empty($this->attributes['password']) //编辑时 + ) { + $this->attributes['password'] = $this->passMd5($value); + } } } }