There is a function to replace the input from the request which is called merge.
I would like to change a value of a nested array so that it can be validated by $this->validate method
..
This is the output of $request->all()
array:2 [
"type" => "customer"
"users" => array:1 [
0 => array:3 [
"name" => "eeee"
"username" => "eeee"
"password" => "123456"
]
]
]
How do I access the username value and change it, provided I use a forloop
for($i=0; $i < count($request->users); $i++){
// i need to access the value here
// i have done something like $request->merge(['users'][$index]['username'] => 'xxx');
// it doesnt work
}
Any solution guys? Thank you.