From 0450226d366b4a41ec04ecc5f3e83c87a283e4cb Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Sat, 1 Apr 2023 21:04:28 +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 --- ActiveQuery.php | 11 +++++++++++ Traits/HasBase.php | 19 ++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/ActiveQuery.php b/ActiveQuery.php index 23df5d1..1974180 100644 --- a/ActiveQuery.php +++ b/ActiveQuery.php @@ -108,6 +108,17 @@ class ActiveQuery extends Component implements ISqlBuilder 'param' => $lists, ]; } + + + /** + * @param bool $asArray + * @return static + */ + public function asArray(bool $asArray = true): static + { + $this->asArray = $asArray; + return $this; + } /** diff --git a/Traits/HasBase.php b/Traits/HasBase.php index f2bac84..5166e9c 100644 --- a/Traits/HasBase.php +++ b/Traits/HasBase.php @@ -34,18 +34,17 @@ abstract class HasBase implements \Database\Traits\Relation * @var ModelInterface */ protected mixed $model; - - + + protected mixed $value = 0; - - + + /** * HasBase constructor. * @param string $name */ public function __construct(public string $name) { - ; } /** @@ -55,16 +54,14 @@ abstract class HasBase implements \Database\Traits\Relation */ public function __call($name, $arguments) { - if (!method_exists($this, $name)) { - $relation = Kiri::getDi()->get(Relation::class); - $relation->getQuery($this->name)->$name(...$arguments); + if ($name !== 'get') { + return di(Relation::class)->getQuery($this->name)->$name(...$arguments); } else { - call_user_func([$this, $name], ...$arguments); + return $this->get(); } - return $this; } - + /** * @param $name * @return mixed