Skip to content

Commit

Permalink
feat: use generics of return type to determine resulting models (#1653)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bloemendaal authored Jan 8, 2025
1 parent bb1caed commit 271682a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Console/ModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,10 +819,14 @@ public function getPropertiesFromMethods($model)
$relation === 'morphTo'
)
) {
$matches = [];
$returnType = $this->getReturnTypeFromDocBlock($reflection);
preg_match('/MorphTo<(.+?)(?:,|>)/i', $returnType, $matches);

// Model isn't specified because relation is polymorphic
$this->setProperty(
$method,
$this->getClassNameInDestinationFile($model, Model::class) . '|\Eloquent',
$matches[1] ?? $this->getClassNameInDestinationFile($model, Model::class) . '|\Eloquent',
true,
null,
$comment,
Expand Down

0 comments on commit 271682a

Please sign in to comment.