Closed stevebauman closed 3 days ago
A fantastic idea that greatly simplifies working with enums! Such an addition enhances usability and aligns perfectly with Laravel's philosophy of making common tasks easier. 👏
Hi @stevebauman , just a thought—maybe you could move isBackedEnum to a helper?
Description
Right now it's possible to retrieve a single enum from a request via the
enum
method, but not an array of them easily.This PR adds an
enums
method to retrieve a potential array of enums provided in a request.Usage
Consider a "webhooks" controller where a user can create a webhook for a given URL and array of events:
This works nicely in tandem with Laravel's built-in
AsEnumArrayObject
cast for Eloquent:https://laravel.com/docs/11.x/eloquent-mutators#casting-arrays-of-enums
Let me know your thoughts! Thanks so much for your time ❤️