Skip to content

Commit

Permalink
do not attempt instantiating non-instantiable models (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
romalytvynenko authored Jul 26, 2024
1 parent e87cfd1 commit b6d8b27
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Support/ResponseExtractor/ModelInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ public function handle()
{
$class = $this->qualifyModel($this->class);

$reflectionClass = new ReflectionClass($class);
if (! $reflectionClass->isInstantiable()) {
return collect([
'instance' => null,
'class' => $class,
'attributes' => collect(),
'relations' => collect(),
]);
}

/** @var Model $model */
$model = app()->make($class);

Expand All @@ -71,6 +81,9 @@ public function type()
}

$modelInfo = $this->handle();
if (! $modelInfo->get('instance')) {
return new ClassDefinition($modelInfo->get('class'));
}

/** @var Model $model */
$model = app()->make($modelInfo->get('class'));
Expand Down

0 comments on commit b6d8b27

Please sign in to comment.