From b10ffd832a69d2ebd876f3ca30a101ff26cf7e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 19 Jan 2022 14:59:46 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E6=94=B9=E5=90=8D"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit fdf58326 --- HasCount.php | 8 ++++---- HasMany.php | 9 +++++---- HasOne.php | 7 +++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/HasCount.php b/HasCount.php index 067e1be..2d4716d 100644 --- a/HasCount.php +++ b/HasCount.php @@ -3,8 +3,8 @@ declare(strict_types=1); namespace Database; -use Exception; use Database\Traits\HasBase; +use Exception; /** * Class HasCount @@ -21,10 +21,10 @@ class HasCount extends HasBase */ public function __call($name, $arguments) { - if (method_exists($this, $name)) { - return call_user_func([$this, $name], ...$arguments); + if (!method_exists($this, $name)) { + return $this->_relation->getQuery($this->model::className())->$name(...$arguments); } - return $this->_relation->getQuery($this->model::className())->$name(...$arguments); + return call_user_func([$this, $name], ...$arguments); } /** diff --git a/HasMany.php b/HasMany.php index 49df7fa..6f57332 100644 --- a/HasMany.php +++ b/HasMany.php @@ -6,10 +6,11 @@ * Time: 13:58 */ declare(strict_types=1); + namespace Database; -use Exception; use Database\Traits\HasBase; +use Exception; /** * Class HasMany @@ -27,10 +28,10 @@ class HasMany extends HasBase */ public function __call($name, $arguments) { - if (method_exists($this, $name)) { - return call_user_func([$this, $name], ...$arguments); + if (!method_exists($this, $name)) { + return $this->_relation->getQuery($this->model::className())->$name(...$arguments); } - return $this->_relation->getQuery($this->model::className())->$name(...$arguments); + return call_user_func([$this, $name], ...$arguments); } /** diff --git a/HasOne.php b/HasOne.php index 4d7e726..3313d35 100644 --- a/HasOne.php +++ b/HasOne.php @@ -27,11 +27,10 @@ class HasOne extends HasBase */ public function __call($name, $arguments) { - if (method_exists($this, $name)) { - return call_user_func([$this, $name], ...$arguments); + if (!method_exists($this, $name)) { + return $this->_relation->getQuery($this->model::className())->$name(...$arguments); } - $this->_relation->getQuery($this->model::className())->$name(...$arguments); - return $this; + return call_user_func([$this, $name], ...$arguments); } /**