From 7ea0bee73ff72eac830bd056896f5a364986b85c Mon Sep 17 00:00:00 2001 From: as2252258 Date: Thu, 28 Apr 2022 03:15:44 +0800 Subject: [PATCH] modify mysql result --- HasCount.php | 11 ++++++----- HasMany.php | 10 ++++++---- HasOne.php | 10 ++++++---- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/HasCount.php b/HasCount.php index 2d4716d..5cccd39 100644 --- a/HasCount.php +++ b/HasCount.php @@ -16,15 +16,16 @@ class HasCount extends HasBase /** * @param $name * @param $arguments - * @return ActiveQuery - * @throws ActiveQuery|static + * @return static */ public function __call($name, $arguments) { if (!method_exists($this, $name)) { - return $this->_relation->getQuery($this->model::className())->$name(...$arguments); - } - return call_user_func([$this, $name], ...$arguments); + $this->_relation->getQuery($this->model::className())->$name(...$arguments); + } else { + call_user_func([$this, $name], ...$arguments); + } + return $this; } /** diff --git a/HasMany.php b/HasMany.php index 6f57332..75ea3a7 100644 --- a/HasMany.php +++ b/HasMany.php @@ -24,14 +24,16 @@ class HasMany extends HasBase /** * @param $name * @param $arguments - * @return ActiveQuery|static + * @return static */ public function __call($name, $arguments) { if (!method_exists($this, $name)) { - return $this->_relation->getQuery($this->model::className())->$name(...$arguments); - } - return call_user_func([$this, $name], ...$arguments); + $this->_relation->getQuery($this->model::className())->$name(...$arguments); + } else { + call_user_func([$this, $name], ...$arguments); + } + return $this; } /** diff --git a/HasOne.php b/HasOne.php index 3313d35..f1ebd42 100644 --- a/HasOne.php +++ b/HasOne.php @@ -23,14 +23,16 @@ class HasOne extends HasBase /** * @param $name * @param $arguments - * @return ActiveQuery|static + * @return static */ public function __call($name, $arguments) { if (!method_exists($this, $name)) { - return $this->_relation->getQuery($this->model::className())->$name(...$arguments); - } - return call_user_func([$this, $name], ...$arguments); + $this->_relation->getQuery($this->model::className())->$name(...$arguments); + } else { + call_user_func([$this, $name], ...$arguments); + } + return $this; } /**