This commit is contained in:
xl
2024-10-23 14:54:04 +08:00
parent 8027effa8c
commit 3244f8cfac
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -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());
}
+1 -1
View File
@@ -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]);
}
/**