I have added this to the Controller:
public function updateMethod(Request $request)
{
$i = 1;
dd($request->input_name_1);
}
Now I wanted to change to this:
public function updateMethod(Request $request)
{
$i = 1;
dd($request->input_name_$i);
}
But I get this error:
syntax error, unexpected '$i' (T_VARIABLE), expecting ')'
So how can I add my custom variable to $request
properly?
CodePudding user response:
You can add custom variables by using bind string in one variable and passing it to $request->
like below code
$i = 1;
$tmp = "input_name_".$i;
dd($request->$tmp);
using this you can get values of custom variables
CodePudding user response:
You can just use basic concatenation in this code. like this one.
public function updateMethod(Request $request)
{
$i = 1;
dd($request->"input_name_".$i);
}