Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add enum support for flags #34

Merged
merged 8 commits into from
Dec 23, 2024
Merged

Conversation

grantholle
Copy link
Contributor

This might be somewhat controversial.

I love the ability to use enums directly when checking things, such as the recent ability to use enums for authorize(). This adds a similar capability to flagging/unflagging/checking flags on models.

The caveat is that BackedEnum was introduced in PHP 8.1, which would theoretically be a breaking change here. While it would be ideal to use Illuminate\Support\enum_value, it's marked as @internal for reasons not immediately clear.

Thanks for your consideration!

@freekmurze
Copy link
Member

Could you rebase against main to solve the conflicts?

…ags into enum-support

# Conflicts:
#	src/Models/Concerns/HasFlags.php
@grantholle
Copy link
Contributor Author

Should be good now @freekmurze!

@freekmurze
Copy link
Member

Seems like the tests fail on L9. Could you take a look at that? I would be ok with bumping the minimum version to L10.

@grantholle
Copy link
Contributor Author

Looks like it's just from php 8.0 being in the matrix. I've removed that, assuming that's the direction that it's headed.

@freekmurze freekmurze merged commit bf69a4d into spatie:main Dec 23, 2024
8 checks passed
@freekmurze
Copy link
Member

Seems good! Thank you for this

@grantholle grantholle deleted the enum-support branch December 23, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants