Skip to content

Commit d529394

Browse files
[12.x] Add a default value to the enum method (#10412)
* Add a default value to the `enum` method * Update requests.md --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent d9a7fc9 commit d529394

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

requests.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,12 @@ use App\Enums\Status;
422422
$status = $request->enum('status', Status::class);
423423
```
424424

425+
You may also provide a default value that will be returned if the value is missing or invalid:
426+
427+
```php
428+
$status = $request->enum('status', Status::class, Status::Pending);
429+
```
430+
425431
If the input value is an array of values that correspond to a PHP enum, you may use the `enums` method to retrieve the array of values as enum instances:
426432

427433
```php

0 commit comments

Comments
 (0)