Skip to content

Commit 9a1c5f3

Browse files
committed
Properly set the JSON payload of FormRequests instead of re-building it
1 parent 0ba0887 commit 9a1c5f3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Illuminate/Foundation/Providers/FormRequestServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ protected function initializeRequest(FormRequest $form, Request $current)
5656
$current->cookies->all(), $files, $current->server->all(), $current->getContent()
5757
);
5858

59+
$form->setJson($current->json());
60+
5961
if ($session = $current->getSession()) {
6062
$form->setLaravelSession($session);
6163
}

src/Illuminate/Http/Request.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,17 @@ public function json($key = null, $default = null)
302302
return data_get($this->json->all(), $key, $default);
303303
}
304304

305+
/**
306+
* Set the JSON payload for the request.
307+
*
308+
* @param array $json
309+
* @return void
310+
*/
311+
public function setJson($json)
312+
{
313+
$this->json = $json;
314+
}
315+
305316
/**
306317
* Get the input source for the request.
307318
*

0 commit comments

Comments
 (0)