mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
feat: use generics of return type to determine resulting models (#1653)
This commit is contained in:
@@ -819,10 +819,14 @@ class ModelsCommand extends Command
|
||||
$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,
|
||||
|
||||
Reference in New Issue
Block a user