This commit is contained in:
2021-11-11 03:03:40 +08:00
parent 8b164c7611
commit 8c3d3b2ce0
2 changed files with 11 additions and 14 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ class CollectionIterator extends \ArrayIterator
*/
protected function newModel($current): ModelInterface
{
return $this->model->attributes = $current;
return $this->model->setAttributes($current);
}
+10 -13
View File
@@ -120,10 +120,11 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
}
/**
* @param string $name
* @param mixed $value
*/
/**
* @param string $name
* @param mixed $value
* @return mixed
*/
private function _setter(string $name, mixed $value): mixed
{
$method = di(Setter::class)->getSetter(static::class, $name);
@@ -488,7 +489,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
*/
public function setAttribute($name, $value): mixed
{
return $this->_attributes[$name] = $this->_setter($name, $value);
return $this->_attributes[$name] = $value;
}
/**
@@ -498,7 +499,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
*/
public function setOldAttribute($name, $value): mixed
{
return $this->_oldAttributes[$name] = $this->_setter($name, $value);
return $this->_oldAttributes[$name] = $value;
}
/**
@@ -511,9 +512,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
if (empty($param)) {
return $this;
}
foreach ($param as $key => $value) {
$this->_attributes[$key] = $this->_setter($key, $value);
}
$this->_attributes = $param;
return $this;
}
@@ -526,10 +525,8 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
if (empty($param) || !is_array($param)) {
return $this;
}
foreach ($param as $key => $val) {
$this->setOldAttribute($key, $val);
}
return $this;
$this->_oldAttributes = $param;
return $this;
}
/**