-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Map by name=>value #57
Comments
Hey, you've already posted the solution. Just put this into your own base namespace App\Enums;
abstract class Enum extends \Spatie\Enum\Enum
{
public static function toArray(): array
{
return array_combine(static::getNames(), static::getValues());
}
}
final class SaveStatus extends \App\Enums\Enum {} |
Hi! Thank you for answering. I tried what you said, but I got error on initialization. Constructor's 3rd argument public function __construct(?string $name = null, ?string $value = null, ?int $index = null) self::$cache[$class][$name]['index'] = static::make($name)->getIndex(); |
@dionysiosarvanitis I've added a PR #58 that drops the usage of |
Works great. Thanks! |
Hi, is there any way to get something like below:
I use names instead of indexes so the mapping should be name=>value
The text was updated successfully, but these errors were encountered: