This commit is contained in:
xl
2024-11-06 20:59:30 +08:00
parent 41166dd998
commit f563126cd0
4 changed files with 9 additions and 10 deletions
+3 -3
View File
@@ -13,6 +13,7 @@ use Database\ModelInterface;
use Database\Collection;
use Database\Relation;
use Kiri;
use Kiri\Di\Context;
/**
* Class HasBase
@@ -57,10 +58,9 @@ abstract class HasBase implements \Database\Traits\Relation
public function __call(string $name, array $arguments)
{
if ($name !== 'get') {
$relation = Kiri::getDi()->get(Relation::class);
$query = $relation->getQuery($this->name);
$query = Context::get(Relation::class)->getQuery($this->name);
if (is_null($query)) {
throw new \Exception('Unknown relation method: ' . $name);
throw new \Exception('Unknown relation key: ' . $this->name);
}
$query->$name(...$arguments);
return $this;