You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
100
100
101
101
```php:no-line-numbers
102
-
$data = request()->all();
102
+
$data = request()->body();
103
103
104
104
// $data = ['name' => '...', 'email' => '...']
105
105
```
106
106
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.
0 commit comments