diff --git a/Database/ActiveRecord.php b/Database/ActiveRecord.php index 58a12e6f..76f8fbfe 100644 --- a/Database/ActiveRecord.php +++ b/Database/ActiveRecord.php @@ -296,7 +296,7 @@ class ActiveRecord extends BaseActiveRecord private function runRelate(): array { $relates = []; - if (empty($this->_with)) { + if (empty($with = $this->getWith())) { return $relates; } foreach ($this->_with as $val) { @@ -305,6 +305,25 @@ class ActiveRecord extends BaseActiveRecord return $relates; } + /** + * @param $data + * @return ActiveRecord + */ + public function setWith($data): static + { + $this->_with = $data; + return $this; + } + + + /** + * @return array|null + */ + public function getWith(): array|null + { + return $this->_with; + } + /** * @param string $modelName diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index c22da743..75b0ccec 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -147,26 +147,6 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess } - /** - * @param $data - * @return BaseActiveRecord - */ - public function setWith($data): static - { - $this->_with = $data; - return $this; - } - - - /** - * @return array|null - */ - public function getWith(): array|null - { - return $this->_with; - } - - /** * @param $name * @param $method