From 0fa0403e57f7b85eef1f4113cd88ff2231da1bd1 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sun, 29 Dec 2024 12:03:42 +0100 Subject: [PATCH] Check if alias is valid --- src/Generator.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Generator.php b/src/Generator.php index 73643b5..332b9a4 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -96,19 +96,19 @@ class Generator $facade = Model::class; $magicMethods = array_key_exists($name, $this->magic) ? $this->magic[$name] : []; $alias = new Alias($this->config, $name, $facade, $magicMethods, $this->interfaces); - if ($alias->isValid()) { - //Add extra methods, from other classes (magic static calls) - if (array_key_exists($name, $this->extra)) { - $alias->addClass($this->extra[$name]); - } + if (!$alias->isValid()) { + throw new \RuntimeException('Cannot generate Eloquent helper'); + } - $eloquentAliases['__root'] = [$alias]; + //Add extra methods, from other classes (magic static calls) + if (array_key_exists($name, $this->extra)) { + $alias->addClass($this->extra[$name]); } $app = app(); return $this->view->make('helper') ->with('namespaces_by_extends_ns', []) - ->with('namespaces_by_alias_ns', $eloquentAliases) + ->with('namespaces_by_alias_ns', ['__root' => [$alias]]) ->with('real_time_facades', []) ->with('helpers', '') ->with('version', $app->version())