File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ This is how they are used:
3737$class->setStatus(Status::Inactive);
3838```
3939
40- ### Enum Labels
40+ ### Custom enum labels
4141
4242By default, enum labels are derived from the constant names. To get enum label, you can use ` ::getLabel ` method on enum class:
4343
@@ -69,6 +69,24 @@ class Status extends Enum
6969$label = Status::getLabel(Status::OnHold);
7070```
7171
72+ ## Listing all enum labels
73+
74+ To get a list of all labels of the enum, you can use ` ::getLabels ` method:
75+
76+ ``` php
77+ // $labels will contain the array - ['Inactive', 'Active', 'waiting']
78+ $labels = Status::getLabels();
79+ ```
80+
81+ ## Listing all enum values
82+
83+ To get a list of all values of the enum, you can use ` ::getValues ` method:
84+
85+ ``` php
86+ // $labels will contain the array - [0, 1, 3]
87+ $labels = Status::getValues();
88+ ```
89+
7290## License
7391
7492The Laravel Orion is open-source software licensed under the [ MIT license] ( https://opensource.org/licenses/MIT ) .
You can’t perform that action at this time.
0 commit comments