Internal enum values | enum | Spatie

 SPATIE

enum
====

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Enum](https://spatie.be/docs/enum/v3)  Usage  Internal enum values

 Version   v3   v2   v1

 Other versions for crawler [v3](https://spatie.be/docs/enum/v3) [v2](https://spatie.be/docs/enum/v2) [v1](https://spatie.be/docs/enum/v1)

- [ Introduction ](https://spatie.be/docs/enum/v3/introduction)
- [ Postcardware ](https://spatie.be/docs/enum/v3/postcardware)
- [ Installation and setup ](https://spatie.be/docs/enum/v3/installation-and-setup)
- [ Questions &amp; issues ](https://spatie.be/docs/enum/v3/questions-and-issues)
- [ Changelog ](https://spatie.be/docs/enum/v3/changelog)
- [ About us ](https://spatie.be/docs/enum/v3/about-us)

Usage
-----

- [ Internal enum values ](https://spatie.be/docs/enum/v3/usage/2-internal-enum-values)
- [ Overriding enum values ](https://spatie.be/docs/enum/v3/usage/3-overriding-enum-values)
- [ Overriding enum labels ](https://spatie.be/docs/enum/v3/usage/4-overriding-enum-labels)
- [ Comparing enums ](https://spatie.be/docs/enum/v3/usage/5-comparing-enums)
- [ Laravel ](https://spatie.be/docs/enum/v3/usage/100-laravel)

 Internal enum values
====================

Creating enums from serialized values is done like so:

```
$status = new StatusEnum('draft');
```

When an enum value doesn't exist, you'll get an error.

Also keep in mind that the core philosophy of this package is that you should *never* use the enum value directly in your code. Always use the object itself. The only place where you're allowed to use `Enum::make()` is to unserialise a value into an enum object. One example is to convert a stored value in a database to an enum object.

If you want to get the value of an enum to store it, you can do this:

```
$status->value;
```

Note that `value` is a read-only property, it cannot be changed.
