In Laravel is there a way to add values to a request array?

Yes, you can add values to a request array in Laravel by using the merge method on the request object. Here's an example of how you could do this:

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

This will add a new key-value pair to the request array. If the key already exists in the array, the value will be overwritten with the new value.

Watch a course Learn object oriented PHP

You can also pass an array of key-value pairs to the merge method to add multiple values at once:

$request->merge(['key1' => 'value1', 'key2' => 'value2']);

Keep in mind that this will only modify the request array for the current request. If you want to persist the changes for future requests, you'll need to store the modified request array in a session or database.