File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -409,8 +409,6 @@ public function castPropertiesType($model)
409409 case 'immutable_datetime ' :
410410 $ realType = '\Carbon\CarbonImmutable ' ;
411411 break ;
412- case AsCollection::class:
413- case AsEnumCollection::class:
414412 case 'collection ' :
415413 $ realType = '\Illuminate\Support\Collection ' ;
416414 break ;
@@ -436,6 +434,18 @@ public function castPropertiesType($model)
436434 continue ;
437435 }
438436
437+ if (Str::startsWith ($ type , AsCollection::class)) {
438+ $ realType = $ this ->getTypeInModel ($ model , $ params [0 ] ?? null ) ?? '\Illuminate\Support\Collection ' ;
439+ }
440+
441+ if (Str::startsWith ($ type , AsEnumCollection::class)) {
442+ $ realType = '\Illuminate\Support\Collection ' ;
443+ $ relatedModel = $ this ->getTypeInModel ($ model , $ params [0 ] ?? null );
444+ if ($ relatedModel ) {
445+ $ realType = $ this ->getCollectionTypeHint ($ realType , $ relatedModel );
446+ }
447+ }
448+
439449 $ realType = $ this ->checkForCastableCasts ($ realType , $ params );
440450 $ realType = $ this ->checkForCustomLaravelCasts ($ realType );
441451 $ realType = $ this ->getTypeOverride ($ realType );
You can’t perform that action at this time.
0 commit comments