I want to remove an existing item from a request parameters that passes in a controller.
Here's my controller:
public function getIndex(Request $request)
{
// I need to remove a parameter from the $request here.
}
Actually, I want to dispatch a request in a controller but when I make a new instance of Request
like this,
$new_request = new Request();
and add some fields to the $new_request
like this:
$request->request->add([
'id' => '2',
'name' => 'test'
]);
Nothing is added! and the dispatch method can not yield a correct response with empty request! But when I use an existing route request, every thing is ok, except extra items and I should get rid of them!
Do you need this?
public function getIndex(Request $request)
{
$request->request->remove('yourParamName');
}