This commit is contained in:
2021-03-04 15:23:17 +08:00
parent d665aa4c4a
commit 8fd715d311
2 changed files with 20 additions and 21 deletions
+20 -1
View File
@@ -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