How to change value of a request parameter in laravel

Use merge():

    'user_id' => $modified_user_id_here,

Simple! No need to transfer the entire $request->all() to another variable.

Read more about Laravel's merge() here:

Try to:

$requestData = $request->all();
$requestData['img'] = $img;

Another way to do it:

$request->merge(['img' => $img]);

Thanks to @JoelHinz for this.

If you want to add or overwrite nested data:

$data['some']['thing'] = 'value';

If you do not inject Request $request object, you can use the global request() helper or \Request:: facade instead of $request