drblhw5731 2015-08-16 22:57
浏览 129
已采纳

如何使用Laravel将数据从一个页面发送到另一个页面?

So I'm using laravel 5.1 and I'm stuck in a weird situation.

I have 2 models Seasonand Tournament and lets say the url to add a Season model is ..../seasons/add and to view the season would be ..../seasons/(id)... standard stuff right?

But now I want to add a tournament from the link ..../seasons/1 and so I click a link that takes me to ..../tournaments/add... how can I send the Season model to that page without submitting a form with hidden input?

Currently I have this setup ..../seasons/1/tournaments/add using blade to generate the links. But this method just doesn't feel right....

Thanks.

  • 写回答

1条回答 默认 最新

  • duanfu7840 2015-08-16 23:07
    关注

    How can I send data from one page to another using Laravel?: I would suggest that you do this from your controller. Take a look at Redirecting With Flashed Session Data, it might come in handy.

    From the Flash Data documentation: "[...] it will only be available during the subsequent HTTP request, and then will be deleted [...]"

    You can send your model, static values or whatever you want using ->with:

    redirect('route')->with('key', 'value');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统