Skip to content

Commit 18fea6f

Browse files
authored
Inaccuracies on Http Request module
1 parent 11b1472 commit 18fea6f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/docs/http/request.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,26 @@ $data = request()->try(['name', 'email'], false, true);
8888

8989
## Getting request data with a default value
9090

91-
There are many situations where you might want to make sure that a value exists in the request before using it, but also want to keep it an optional value for users. You can use the `getOrDefault()` method to do this. The `getOrDefault()` method takes a key and a default value as arguments and returns the value associated with the key if it exists, or the default value if it doesn't.
91+
There are many situations where you might want to make sure that a value exists in the request before using it, but also want to keep it an optional value for users. You can use the `params()` method to do this. The `params()` method takes a key and a default value as arguments and returns the value associated with the key if it exists, or the default value if it doesn't.
9292

9393
```php:no-line-numbers
94-
$data = request()->getOrDefault('name', 'John Doe');
94+
$data = request()->params('name', 'John Doe');
9595
```
9696

9797
## Getting all request data
9898

99-
You can use the `all()` method to get all the data in the request. It returns an array of all the data in the request.
99+
You can use the `body()` method to get all the data in the request. It returns an array of all the data in the request.
100100

101101
```php:no-line-numbers
102-
$data = request()->all();
102+
$data = request()->body();
103103
104104
// $data = ['name' => '...', 'email' => '...']
105105
```
106106

107-
Every time you call the `all()` method, Leaf will sanitize the data in the request. If you want to disable data sanitization, you can pass `false` as a parameter to the `all()` method.
107+
Every time you call the `body()` method, Leaf will sanitize the data in the request. If you want to disable data sanitization, you can pass `false` as a parameter to the `body()` method.
108108

109109
```php:no-line-numbers
110-
$data = request()->all(false);
110+
$data = request()->body(false);
111111
```
112112

113113
## Request type specific methods

0 commit comments

Comments
 (0)