This commit is contained in:
xl
2024-11-06 20:36:59 +08:00
parent 32164f66ab
commit 28beb3678e
+6 -1
View File
@@ -52,12 +52,17 @@ abstract class HasBase implements \Database\Traits\Relation
* @param string $name * @param string $name
* @param array $arguments * @param array $arguments
* @return $this|mixed * @return $this|mixed
* @throws \Exception
*/ */
public function __call(string $name, array $arguments) public function __call(string $name, array $arguments)
{ {
if ($name !== 'get') { if ($name !== 'get') {
$relation = Kiri::getDi()->get(Relation::class); $relation = Kiri::getDi()->get(Relation::class);
$relation->getQuery($this->name)->$name(...$arguments); $query = $relation->getQuery($this->name);
if (is_null($query)) {
throw new \Exception('Unknown relation method: ' . $name);
}
$query->$name(...$arguments);
return $this; return $this;
} else { } else {
return $this->get(); return $this->get();