Note: my question is not duplicate
I have form in out of site and use web api laravel 5.7
, now is send these parameters as post:
estate: "545345"
id_number: "43534545"
serial_number: "435435345"
type[code_id]: "45345345435"
type[company]: ""
type[country]: ""
type[maintenance_period]: ""
type[model]: "5435345435"
type[name]: "5345345345"
waranty[company_id]: "0"
waranty[duration]: ""
waranty[end]: ""
waranty[start]: ""
part of form:
<input type="text" name="estate" required="">
<input type="text" name="id_number" required="">
<input type="text" name="type[code_id]">
<input type="text" name="type[company]">
Now I want to get type
and waranty
array: same as for example:
$type = ['name' => 'test','company' => '...', 'model' => '...' ]
I try these codes:
$type = $request->input('type.*'); // NULL
and
$type = $request->input('type'); // NULL
and
$type = Input::get('type'); // NULL
and
$in = $request->all();
$type = $in['type']; // NULL
AND
$request->get('type'); // NULL
AND
$request->post('type') // NULL
Doesn't work :( , only I can get single variable, by this method: (but I need array)
$in = $request->all();
$in['type[code_id]'] ;
And I test type[][code_id]
,type[][name]
,... in form but not work :(
My axios
method:
serial = function (id) {
var srl = $(id).serializeArray();
var post = {};
for (const k in srl) {
let item = srl[k];
post[item.name] = item.value;
}
return post;
}
axios.post(url, serial("#frm")).then(function (res) {// succs axios ;
console.log(res);
}).catch(err => {// error axios ;
console.log(err);
}); // end axios ;
What is the Laravel native solution ? for this problem ?
note: I can create an function for solve this problem but I need laravel native solution.