laravel-ide-helper icon indicating copy to clipboard operation
laravel-ide-helper copied to clipboard

Support for casts AsEnumCollection

Open Braunson opened this issue 1 year ago • 3 comments

Summary

Here's my example casts method 'preferences':

protected function casts(): array
    {
        return [
            'preferences' => AsEnumCollection::of(UserPreferences::class),
        ];
    }
}

Currently the IDE helper generates the property as AsEnumCollection. If I attempt to use $user->preferences->anyCollectionMethod() it returns an undefined method error.

Instead the IDE helper should at the minimum generate returning an Eloquent Collection instance.

 * @property \Illuminate\Database\Eloquent\Collection $preferences

Braunson avatar May 31 '24 18:05 Braunson

Can you make a PR?

mfn avatar Jun 01 '24 03:06 mfn

I tried v3.1.0 and it only seems to work with AsEnumCollection::class, not AsEnumCollection::of(MyEnum::class). Am I missing something?

uno-sw avatar Aug 01 '24 23:08 uno-sw

After reading the code for a while, I found out that it is not supported yet (and AsCollection::using is not supported either). I'll be happy to create a PR for it when I have time :)

uno-sw avatar Aug 02 '24 01:08 uno-sw