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

前端 未结 13 2187
闹比i
闹比i 2020-12-07 15:24

I come across a situation in Laravel while calling a store() or update() method with Request parameter to add some additional value to the request before calling Eloquent fu

13条回答
  •  臣服心动
    2020-12-07 16:00

    To add a new parameter for ex: newParam to the current Request Object, you can do:

    $newParam = "paramvalue";
    $request->request->add(['newParam' => $newParam]);
    

    After adding the new parameter, you would be able to see this newly added parameter to the Request object by:

    dd($request);//prints the contents of the Request object
    

提交回复
热议问题