I have a form which includes input names with arrays, examples:
user_profile[birth_day]
user_profile[birth_month]
user_profile[birth_year]
user_profile[birthdate]
now i want to combine them and make a new request property.
i found a solution but i know it's bad practice:
$user_profile['birthdate'] = Carbon::parse(implode("-", [$request->user_profile['birth_day'], $request->user_profile['birth_month'], $request->user_profile['birth_year']]))->format('Y-m-d');
$request->request->add(['user_profile' => $user_profile+$request->user_profile]);
When i get $request->user_profile['birthdate']
it returns the correct input, if filled in. But when i try to modify $request->user_profile['birthdate']
when it is empty with:
$reuest->user_profile['birthdate'] = Carbon::parse(implode("-", [$request->user_profile['birth_day'], $request->user_profile['birth_month'],
$request->user_profile['birth_year']]))->format('Y-m-d');
i get the following error:
Indirect modification of overloaded property Illuminate\Http\Request::$user_profile has no effect