@@ -51,11 +51,14 @@ return [
5151 ]
5252];
5353```
54+
5455You may then access these localized values using the ` ->label() ` or ` ::labelFor() ` methods
56+
5557``` php
5658VolumeUnitEnum::MILLIGRAMS->label(); // "mg"
5759VolumeUnitEnum::labelFor(VolumeUnitEnum::TONNE); // "t"
5860```
61+
5962If you do not specify a label in the lang file these methods will return the translation key e.g. ` enums.\\App\\Enums\\VolumeUnitEnum.GRAMS `
6063
6164### Meta data
@@ -87,6 +90,7 @@ public function withMeta(): array
8790 };
8891}
8992```
93+
9094If you do not specify a ` withMeta ` method, meta will be an empty array.
9195
9296## Other methods
@@ -106,15 +110,17 @@ returns
106110``` php
107111[
108112 [
109- 'value' => 'Milligrams',
113+ 'name' => 'MILLIGRAMS'
114+ 'value' => 'MILLIGRAMS',
110115 'label' => 'mg',
111116 'meta' => [
112117 'background_color' => 'bg-green-100',
113118 'text_color' => 'text-green-800',
114119 ],
115120 ],
116121 [
117- 'value' => 'Grams',
122+ 'name' => 'GRAMS',
123+ 'value' => 'GRAMS',
118124 'label' => 'g',
119125 'meta' => [
120126 'background_color' => 'bg-red-100',
@@ -125,6 +131,27 @@ returns
125131]
126132```
127133
134+ ### names
135+
136+ Returns an array of all enum values.
137+
138+ #### Usage
139+
140+ ``` php
141+ VolumeUnitEnum::names();
142+ ```
143+
144+ returns
145+
146+ ``` php
147+ [
148+ 'MILLIGRAMS',
149+ 'GRAMS',
150+ 'KILOGRAMS',
151+ 'TONNE',
152+ ]
153+ ```
154+
128155### values
129156
130157Returns an array of all enum values.
@@ -181,9 +208,9 @@ returns
181208
182209``` php
183210[
184- 'MILLIGRAM '=>'mg',
185- 'GRAM ' =>'g',
186- 'KILOGRAM ' =>'kg',
211+ 'MILLIGRAMS '=>'mg',
212+ 'GRAMS ' =>'g',
213+ 'KILOGRAMS ' =>'kg',
187214 'TONNE' =>'t',
188215]
189216```
@@ -202,7 +229,8 @@ returns
202229
203230``` php
204231[
205- 'value' => 'Milligrams',
232+ 'name' => 'MILLIGRAMS'
233+ 'value' => 'MILLIGRAMS',
206234 'label' => 'mg',
207235 'meta' => [
208236 'color' => 'bg-green-100',
@@ -216,7 +244,8 @@ returns
216244An alias for toArray.
217245
218246### isA/isAn
219- Allows you to check if an enum is a given value. Returns a boolean.
247+
248+ Allows you to check if an enum is a given value. Returns a boolean.
220249> ** Note**
221250> ` isAn ` is just an alias for ` isA ` .
222251
@@ -228,6 +257,7 @@ VolumeUnitEnum::MILLIGRAMS->isA(VolumeUnitEnum::MILLIGRAMS); //true
228257```
229258
230259### isNotA/isNotAn
260+
231261Allows you to check if an enum is not a given value. Returns a boolean.
232262> ** Note**
233263> ` isNotAn ` is just an alias for ` isNotA ` .
@@ -240,6 +270,7 @@ VolumeUnitEnum::MILLIGRAMS->isA(VolumeUnitEnum::MILLIGRAMS); //false
240270```
241271
242272### isAny
273+
243274Allows you to check if an enum is contained in an array. Returns a boolean.
244275
245276#### Usage
@@ -250,6 +281,7 @@ VolumeUnitEnum::MILLIGRAMS->isAny([VolumeUnitEnum::GRAMS, VolumeUnitEnum::MILLIG
250281```
251282
252283### isNotAny
284+
253285Allows you to check if an enum is not contained in an array. Returns a boolean.
254286
255287#### Usage
0 commit comments