【问题标题】:Send data using redirect action using Laravel 7使用 Laravel 7 使用重定向操作发送数据
【发布时间】:2021-05-02 07:35:56
【问题描述】:

我需要使用类似这样的东西:

return redirect()->action([HomeController::class, 'index'])->with('data'=>$data);

但我不知道怎么做?

【问题讨论】:

  • 我认为this 是您要找的。​​span>

标签: php laravel redirect


【解决方案1】:

Action 方法接受两个都是数组的参数。第二个数组是键的关联数组,作为参数名称和参数值的值。 在你的情况下,它会是

return redirect()->action(
    [HomeController::class, 'index'], 
    ['data' => $data]
);

Docs.

【讨论】:

  • 不客气。如果确实解决了您的问题,请随时接受答案(并投票)。编码愉快。
猜你喜欢
  • 2014-09-24
  • 2016-05-31
  • 1970-01-01
  • 2015-08-13
  • 2015-07-11
  • 1970-01-01
  • 2016-09-29
  • 1970-01-01
  • 2023-04-05
相关资源
最近更新 更多