diff --git a/Traits/HasBase.php b/Traits/HasBase.php index 22dd975..337ce39 100644 --- a/Traits/HasBase.php +++ b/Traits/HasBase.php @@ -52,12 +52,17 @@ abstract class HasBase implements \Database\Traits\Relation * @param string $name * @param array $arguments * @return $this|mixed + * @throws \Exception */ public function __call(string $name, array $arguments) { if ($name !== 'get') { $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; } else { return $this->get();