Created
June 23, 2023 15:12
-
-
Save praisedare/df931e62d2c6e4e635e26eb31a7e8eb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds a static `values` method that returns an array | |
* containing the values of a backed enum | |
*/ | |
trait ListableEnumValues | |
{ | |
static function values(): array | |
{ | |
return collect(self::cases())->pluck('value')->all(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment