dongqing314511 2017-03-08 14:58
浏览 47
已采纳

Laravel trait重定向回会话

//inside of trait method
redirect()->back()->with('success', $response['message'])->send();

I have a method inside of trait required redirect back to previous page with flash session, but about code only redirect back without session. (controller call this trait method)

I also tried Session::flash(); but its not working too

this method will use many times in my app, therefor I need this inside of my trait

  • 写回答

2条回答 默认 最新

  • doulan0297 2017-03-08 16:48
    关注

    You have to return & I don't know whether you need to use send or not so use like

    return redirect()->back()->with('success', $response['message']);
    

    See how laravel do it https://github.com/laravel/framework/blob/5.4/src/Illuminate/Foundation/Exceptions/Handler.php#L158-L160

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊