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

Usually, you do not want to add anything to a Request object, it’s better to use collection and put() helper:

function store(Request $request) 
{
    // some additional logic or checking
    User::create(array_merge($request->all(), ['index' => 'value']));
}

Or you could union arrays:

User::create($request->all() + ['index' => 'value']);

But, if you really want to add something to a Request object, do this:

$request->request->add(['variable' => 'value']); //add request

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)