Skip to content

Commit d663430

Browse files
committed
chore: use named parameters in samples
1 parent 1d6c276 commit d663430

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ $contact->type = ContactType::EMAIL;
9393
echo $contact->type->label(); // "Email"
9494

9595
// Get label in specific locale
96-
echo $contact->type->label(null, 'fr'); // "E-mail"
96+
echo $contact->type->label(locale: 'fr'); // "E-mail"
9797
```
9898

9999
### Multiple Label Types
@@ -118,22 +118,27 @@ $options = ContactType::forSelect();
118118
// Returns: ['email' => 'Email', 'phone' => 'Phone', 'sms' => 'SMS']
119119

120120
// With placeholder
121-
$options = ContactType::forSelect(null, null, 'Choose contact type');
122-
// Returns: ['' => 'Choose contact type', 'email' => 'Email', ...]
121+
$options = ContactType::forSelect(placeHolder: 'Choose contact type');
122+
// Returns: ['' => 'Choose contact type', 'email' => 'Email', 'phone' => 'Phone', 'sms' => 'SMS']
123123

124124
// With specific label type
125-
$options = ContactType::forSelect('description');
125+
$options = ContactType::forSelect(label: 'description');
126+
// Returns: ['email' => 'Send via email', 'phone' => 'Call by phone', 'sms' => 'Send text message']
126127

127128
// With specific locale
128-
$options = ContactType::forSelect(null, 'fr');
129+
$options = ContactType::forSelect(locale: 'fr');
130+
// Returns: ['email' => 'E-mail', 'phone' => 'Téléphone', 'sms' => 'SMS']
129131

130132
// Exclude specific cases
131-
$options = ContactType::forSelect(null, null, null, [ContactType::SMS]);
133+
$options = ContactType::forSelect(excepted: [ContactType::SMS]);
132134
// Returns only EMAIL and PHONE options
135+
// Returns: ['email' => 'Email', 'phone' => 'Phone']
133136

134137
// Include only specific cases
135-
$options = ContactType::forSelect(null, null, null, null, [ContactType::EMAIL, ContactType::PHONE]);
138+
$options = ContactType::forSelect(only: [ContactType::EMAIL, ContactType::PHONE]);
136139
// Returns only EMAIL and PHONE options
140+
// Returns: ['email' => 'Email', 'phone' => 'Phone']
141+
137142

138143
// Get structured options array
139144
$options = ContactType::options();
@@ -142,21 +147,24 @@ $options = ContactType::options();
142147
// ['value' => 'phone', 'label' => 'Phone'],
143148
// ['value' => 'sms', 'label' => 'SMS']
144149
// ]
150+
151+
// With custom label and locale
152+
$options = ContactType::options(label: 'description', locale: 'fr');
145153
```
146154

147155
### Blade Usage
148156

149157
```blade
150158
<!-- In a select input -->
151159
<select name="contact_type">
152-
@foreach(ContactType::forSelect(null, null, 'Select type') as $value => $label)
160+
@foreach(ContactType::forSelect(placeHolder: 'Select type') as $value => $label)
153161
<option value="{{ $value }}">{{ $label }}</option>
154162
@endforeach
155163
</select>
156164
157165
<!-- Select with filtered options -->
158166
<select name="preferred_contact">
159-
@foreach(ContactType::forSelect(null, null, 'Choose method', [ContactType::SMS]) as $value => $label)
167+
@foreach(ContactType::forSelect(placeHolder: 'Choose method', excepted: [ContactType::SMS]) as $value => $label)
160168
<option value="{{ $value }}">{{ $label }}</option>
161169
@endforeach
162170
</select>
@@ -186,8 +194,8 @@ $values = ContactType::values();
186194
// Returns: ['email', 'phone', 'sms']
187195

188196
// Filter enum cases
189-
$filtered = ContactType::filterCases([ContactType::SMS]); // Exclude SMS
190-
$onlyEmailPhone = ContactType::filterCases(null, [ContactType::EMAIL, ContactType::PHONE]); // Only EMAIL and PHONE
197+
$filtered = ContactType::filterCases(excepted: [ContactType::SMS]); // Exclude SMS
198+
$onlyEmailPhone = ContactType::filterCases(only: [ContactType::EMAIL, ContactType::PHONE]); // Only EMAIL and PHONE
191199
```
192200

193201
## Advanced Features

0 commit comments

Comments
 (0)