From ecfe15c3ac0c7ad6bf3143f943ca24c8199e2474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Mon, 10 Apr 2023 17:45:29 +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 | 2 +- HasMany.php | 2 +- HasOne.php | 2 +- Relation.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/HasCount.php b/HasCount.php index 85acb1e..5abac52 100644 --- a/HasCount.php +++ b/HasCount.php @@ -21,7 +21,7 @@ class HasCount extends HasBase public function get(): array|ModelInterface|null { $relation = Kiri::getDi()->get(Relation::class); - return $relation->getQuery($this->name)->count(); + return $relation->get($this->name); } } diff --git a/HasMany.php b/HasMany.php index 56053b1..ea68f3a 100644 --- a/HasMany.php +++ b/HasMany.php @@ -29,6 +29,6 @@ class HasMany extends HasBase public function get(): array|Collection|null { $relation = Kiri::getDi()->get(Relation::class); - return $relation->getQuery($this->name)->get(); + return $relation->get($this->name); } } diff --git a/HasOne.php b/HasOne.php index 3804a38..613a4e7 100644 --- a/HasOne.php +++ b/HasOne.php @@ -28,6 +28,6 @@ class HasOne extends HasBase public function get(): array|ModelInterface|null { $relation = Kiri::getDi()->get(Relation::class); - return $relation->getQuery($this->name)->first(); + return $relation->first($this->name); } } diff --git a/Relation.php b/Relation.php index 1f1b360..96ac78d 100644 --- a/Relation.php +++ b/Relation.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Database; +use Exception; use Kiri\Abstracts\Component; use Kiri\Di\Context; @@ -14,8 +15,6 @@ use Kiri\Di\Context; class Relation extends Component { - private array $_relations = []; - /** @var ActiveQuery[] $_query */ private array $_query = []; @@ -52,6 +51,7 @@ class Relation extends Component /** * @param string $_identification * @return mixed + * @throws Exception */ public function first(string $_identification): mixed {