This commit is contained in:
2022-09-29 22:51:41 +08:00
parent 7554f6b161
commit f87a3c386f
4 changed files with 32 additions and 63 deletions
+1 -17
View File
@@ -21,22 +21,6 @@ use Exception;
class HasMany extends HasBase
{
/**
* @param $name
* @param $arguments
* @return static
*/
public function __call($name, $arguments)
{
if (!method_exists($this, $name)) {
$key = $this->model::className() . '_' . $this->primaryId . '_' . $this->value;
$this->_relation->getQuery($key)->$name(...$arguments);
} else {
call_user_func([$this, $name], ...$arguments);
}
return $this;
}
/**
* @return array|null|Collection
* @throws Exception
@@ -44,6 +28,6 @@ class HasMany extends HasBase
public function get(): array|Collection|null
{
$key = $this->model::className() . '_' . $this->primaryId . '_' . $this->value;
return $this->_relation->get($key);
return $this->_relation->get(md5($key));
}
}