Support AsCollection::of($map), AsCollection::using($class, $map) (#1714)

* Support `AsCollection::of($map)`, `AsCollection::using($class, $map)`

* test compatibility(`of($map)`,`using($class, $map)` compiled), only laravel `>=12.10`
This commit is contained in:
erikn69
2025-07-17 07:23:52 +02:00
committed by GitHub
parent 1815a6140a
commit 6c4ba2ad38
4 changed files with 34 additions and 1 deletions
+5 -1
View File
@@ -475,7 +475,11 @@ class ModelsCommand extends Command
}
if (Str::startsWith($type, AsCollection::class)) {
$realType = $this->getTypeInModel($model, $params[0] ?? null) ?? '\Illuminate\Support\Collection';
$realType = $this->getTypeInModel($model, $params[0] ?? null) ?: '\Illuminate\Support\Collection';
$relatedModel = $this->getTypeInModel($model, $params[1] ?? null);
if ($relatedModel) {
$realType = $this->getCollectionTypeHint($realType, $relatedModel);
}
}
if (Str::startsWith($type, AsEnumCollection::class)) {