From bc2b60b42e452472043867a4f195ea01208a9f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Tue, 19 Oct 2021 18:27:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ActiveQuery.php | 5 +++-- src/Base/CollectionIterator.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ActiveQuery.php b/src/ActiveQuery.php index 6f4a7ce..3f8841d 100644 --- a/src/ActiveQuery.php +++ b/src/ActiveQuery.php @@ -198,7 +198,9 @@ class ActiveQuery extends Component implements ISqlBuilder public function all(): Collection|array { $data = $this->execute($this->builder->all())->all(); - + if (!empty($this->with)){ + $this->modelClass->setWith($this->with); + } $collect = new Collection($this, $data, $this->modelClass); if ($this->asArray) { return $collect->toArray(); @@ -223,7 +225,6 @@ class ActiveQuery extends Component implements ISqlBuilder */ public function getWith(ModelInterface $model): ModelInterface { - var_dump($this->with); if (empty($this->with) || !is_array($this->with)) { return $model; } diff --git a/src/Base/CollectionIterator.php b/src/Base/CollectionIterator.php index 6614fc7..1812257 100644 --- a/src/Base/CollectionIterator.php +++ b/src/Base/CollectionIterator.php @@ -68,7 +68,7 @@ class CollectionIterator extends \ArrayIterator if (is_array($current = parent::current())) { $current = $this->newModel($current); } - return $this->query->getWith($current); + return $current; }