Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support for casts AsEnumCollection #1553

Open
Braunson opened this issue May 31, 2024 · 3 comments
Open

Support for casts AsEnumCollection #1553

Braunson opened this issue May 31, 2024 · 3 comments

Comments

@Braunson
Copy link
Contributor

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
@mfn
Copy link
Collaborator

mfn commented Jun 1, 2024

Can you make a PR?

@uno-sw
Copy link
Contributor

uno-sw commented Aug 1, 2024

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
Copy link
Contributor

uno-sw commented Aug 2, 2024

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 :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants