From 3244f8cfac987a0430dd64da66aa3180f809334f Mon Sep 17 00:00:00 2001 From: xl Date: Wed, 23 Oct 2024 14:54:04 +0800 Subject: [PATCH] eee --- Base/Model.php | 6 +++++- Relation.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Base/Model.php b/Base/Model.php index 90407cb..e8f3279 100644 --- a/Base/Model.php +++ b/Base/Model.php @@ -23,6 +23,7 @@ use Database\ModelInterface; use Database\Relation; use Database\SqlBuilder; use Exception; +use Kiri\Di\Context; use Kiri; use Kiri\Abstracts\Component; use ReturnTypeWillChange; @@ -597,7 +598,10 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \ */ public function getRelation(): ?Relation { - return Kiri::getDi()->get(Relation::class); + if (Context::exists(Relation::class)) { + return Context::get(Relation::class); + } + return Context::set(Relation::class, new Relation()); } diff --git a/Relation.php b/Relation.php index 38512ac..d8c08b1 100644 --- a/Relation.php +++ b/Relation.php @@ -34,7 +34,7 @@ class Relation extends Component */ public function hasIdentification(string $identification): bool { - return isset($this->_query[$identification]) && $this->_query[$identification] instanceof ActiveQuery; + return isset($this->_query[$identification]); } /**