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 private function runRelate(): array
{ {
$relates = []; $relates = [];
if (empty($this->_with)) { if (empty($with = $this->getWith())) {
return $relates; return $relates;
} }
foreach ($this->_with as $val) { foreach ($this->_with as $val) {
@@ -305,6 +305,25 @@ class ActiveRecord extends BaseActiveRecord
return $relates; 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 * @param string $modelName
-20
View File
@@ -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 $name
* @param $method * @param $method