diff --git a/src/Base/AbstractCollection.php b/src/Base/AbstractCollection.php index dd46ee5..a5dad57 100644 --- a/src/Base/AbstractCollection.php +++ b/src/Base/AbstractCollection.php @@ -134,7 +134,7 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat return NULL; } if (!($this->_item[$offset] instanceof ModelInterface)) { - return $this->model::populate($this->_item[$offset]); + return $this->model->populates($this->_item[$offset]); } return $this->_item[$offset]; } diff --git a/src/Base/CollectionIterator.php b/src/Base/CollectionIterator.php index acfa468..36a1c26 100644 --- a/src/Base/CollectionIterator.php +++ b/src/Base/CollectionIterator.php @@ -56,7 +56,7 @@ class CollectionIterator extends \ArrayIterator */ protected function newModel($current): ModelInterface { - return $this->model::populate($current); + return $this->model->populates($current); } diff --git a/src/Base/Model.php b/src/Base/Model.php index 5ed51c9..386faaa 100644 --- a/src/Base/Model.php +++ b/src/Base/Model.php @@ -612,7 +612,6 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T */ public function save($data = NULL): static|bool { - var_dump($this->_attributes); if (!is_null($data)) { $this->_attributes = merge($this->_attributes, $data); } @@ -621,13 +620,25 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T } [$change, $condition, $fields] = $this->separation(); if (!$this->isNewExample) { - var_dump($fields, $condition, $change); return $this->updateInternal($fields, $condition, $change); } return $this->insert($change, $fields); } + /** + * @param $value + * @return $this + */ + public function populates($value): static + { + $this->_attributes = $value; + $this->_oldAttributes = $value; + $this->setIsCreate(FALSE); + return $this; + } + + /** * @param array|null $rule * @return bool @@ -846,7 +857,6 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T public function refresh(): static { $this->_oldAttributes = $this->_attributes; - var_dump($this->_attributes); return $this; }