From 7554f6b16162896bf9c198e80859eb4a52a66c58 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Thu, 29 Sep 2022 22:38:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HasCount.php | 3 ++- HasMany.php | 3 ++- HasOne.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/HasCount.php b/HasCount.php index 33e53e3..c8f354e 100644 --- a/HasCount.php +++ b/HasCount.php @@ -21,7 +21,8 @@ class HasCount extends HasBase public function __call($name, $arguments) { if (!method_exists($this, $name)) { - $this->_relation->getQuery($this->model::className())->$name(...$arguments); + $key = $this->model::className() . '_' . $this->primaryId . '_' . $this->value; + $this->_relation->getQuery($key)->$name(...$arguments); } else { call_user_func([$this, $name], ...$arguments); } diff --git a/HasMany.php b/HasMany.php index 086738c..4e5dc3b 100644 --- a/HasMany.php +++ b/HasMany.php @@ -29,7 +29,8 @@ class HasMany extends HasBase public function __call($name, $arguments) { if (!method_exists($this, $name)) { - $this->_relation->getQuery($this->model::className())->$name(...$arguments); + $key = $this->model::className() . '_' . $this->primaryId . '_' . $this->value; + $this->_relation->getQuery($key)->$name(...$arguments); } else { call_user_func([$this, $name], ...$arguments); } diff --git a/HasOne.php b/HasOne.php index 9fa334a..d2acfb8 100644 --- a/HasOne.php +++ b/HasOne.php @@ -28,7 +28,8 @@ class HasOne extends HasBase public function __call($name, $arguments) { if (!method_exists($this, $name)) { - $this->_relation->getQuery($this->model::className())->$name(...$arguments); + $key = $this->model::className() . '_' . $this->primaryId . '_' . $this->value; + $this->_relation->getQuery($key)->$name(...$arguments); } else { call_user_func([$this, $name], ...$arguments); }