Skip to content

Commit

Permalink
Check if alias is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh committed Dec 29, 2024
1 parent 97e3b5e commit 0fa0403
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,19 @@ public function generateEloquent()
$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())
Expand Down

0 comments on commit 0fa0403

Please sign in to comment.