Lesson 11/20 · 8:00 min
Now that PHP (>= 8.1) supports enums natively and Laravel has native enum type casting this has become so much easier to deal with. Just create the enum you want (has to be "backed") and use it in a model cast.
Eloquent mutators - Enum Casting, in the Laravel docs.
UPDATE: https://www.youtube.com/watch?v=uEBHJVK-Ibg&ab_channel=LaravelDaily
watch this
Now that PHP (>= 8.1) supports enums natively and Laravel has native enum type casting this has become so much easier to deal with. Just create the enum you want (has to be "backed") and use it in a model cast.
Eloquent mutators - Enum Casting, in the Laravel docs.
UPDATE: https://www.youtube.com/watch?v=uEBHJVK-Ibg&ab_channel=LaravelDaily
watch this