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

前端 未结 13 2138
闹比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 15:58

    enough said on this subject but i couldn't resist to add my own answer. I believe the simplest approach is

    request()->merge([ 'foo' => 'bar' ]);
    

提交回复
热议问题