Skip to content

Commit 04177bf

Browse files
committed
feature: add docs for getLabels and getValues methods
1 parent 99b1e05 commit 04177bf

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff 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

4242
By 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

7492
The Laravel Orion is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).

0 commit comments

Comments
 (0)