Answer the question
In order to leave comments, you need to log in
How does laravel accept an array from js?
Silly question, but I'm confused. There is a script on the client that sends data to the server via ajax.
Sends data via axios, it looks like this:
this.$axios.post('/someurl', {
param1: 'value1',
param2: 'value2',
param3: ['value3', 'value4', 'value5']
})
$param1 = request()->input('param1');
$param2 = request()->input('param2');
$param3 = request()->input('param3');
Answer the question
In order to leave comments, you need to log in
By default, axios actually sends application/json, not application/x-www-form-urlencoded
You can check what exactly is sent to devtools, for example.
Perhaps Laravel automatically expands all of this into "regular" fields.
UPD: It looks like it is ( tyts ).
In its "raw" form, json was (in version 4.2, for example) available via Request::json->all()
, then it was removed from the documentation.
Perhaps in the future (or already?) Will be removed from the code. Too lazy to check.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question