How to easily change the value of a request parameter in Laravel.
You can do this by using the merge method to merge an array or collection with the original.
This works by overwriting the value of the key if there is a match.
In the example below,
$request->password will become encrypted.
$request->merge([ 'password' => Crypt::encryptString($request->password), ]);
As the password key on the $request array will be overwritten.
If the key doesn’t exist, the key and value will just be added in rather than overwritten.