This commit is contained in:
as2252258@163.com
2021-04-24 19:48:42 +08:00
parent 1867083b14
commit 0077948d12
2 changed files with 13 additions and 3 deletions
+10
View File
@@ -81,6 +81,16 @@ class Annotation extends Component
} }
/**
* @param string $class
* @return array
*/
public function getRelateMethods(string $class): array
{
return $this->_model_relate[$class] ?? [];
}
/** /**
* @param string $class * @param string $class
+3 -3
View File
@@ -732,10 +732,10 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
*/ */
public function getRelate($name): mixed public function getRelate($name): mixed
{ {
if (!isset($this->_relate[$name])) { if (empty($this->_relate[$name])) {
return NULL; $this->_relate = Snowflake::getAnnotation()->getRelateMethods(get_called_class());
} }
return $this->_relate[$name]; return $this->_relate[$name] ?? null;
} }