In Laravel how do I get the request body? I am trying $request->get(‘data’) but I get a null result. I am doing a POST request to a store function in my controller but I am unable to get the POSTed data.
public function store(Request $request)
{
$test = $request->get('data');
}
Retrieving All Input Data
$data = $request->all();
Retrieving An Input Value
$name = $request->input('name');
Retrieving An Input Value with default value
$name = $request->input('name', 'Sally');
For details read Laravel document here https://laravel.com/docs/5.6/requests
In Laravel, you can fetch the request input data by using $request->all(). This will then return the input data as an array. You can find more in the docs here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With