How to change value of a request parameter in laravel

前端 未结 7 1740
太阳男子
太阳男子 2020-12-02 21:40

I need to change value of my request parameter like this:

$request->name = \"My Value!\";

I use

相关标签:
7条回答
  • 2020-12-02 22:30

    Try to:

    $requestData = $request->all();
    $requestData['img'] = $img;
    

    Another way to do it:

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

    Thanks to @JoelHinz for this.

    If you want to add or overwrite nested data:

    $data['some']['thing'] = 'value';
    $request->merge($data);
    

    If you do not inject Request $request object, you can use the global request() helper or \Request:: facade instead of $request

    0 讨论(0)
提交回复
热议问题