How to send data using redirect with Laravel(如何使用 Laravel 重定向发送数据)
问题描述
我开发了一个 API 来在页面加载时显示弹出消息.
I developed an API to show a pop up message when the page loaded.
并非所有页面都使用弹出式 API.例如,如果用户转到 show($id) 页面,则不需要触发弹出式 API.但在某些特殊情况下,我需要触发弹出窗口.
Not all the pages use the pop up API. For example, if the user go to the show($id) page, that doesn't required the pop up api to fire. but in some special cases, I need the pop up to be fired.
这是我的代码,**此代码只是为了说明我的观点,而不是实际的工作代码**
Here is my code, ** this code is just to illustrate my point, not an actual working code**
public function store(){
validating the input
saving them
$id = get the id
return Redirect::route('clients.show, $id')
}
在显示功能中我这样做:
and in the show function I do this:
public function show($id){
$client =Client::find($id)
return View::make('clients.profife')->with(array(
'data' => $client
))
我的问题
有没有办法让我可以将数据从 store 函数发送到 show 函数 使用 Redirect::route ?然后在 show 函数中,我检查是否这个 show 函数,我检查这个数据是否已经发送了什么,然后我决定是否触发弹出 api 或不是.
My question
Is there a way so I can send a data from the store function to the show function using Redirect::route ? and then in the show function, I check if this show function, I check if this data has been sent of what and then I decide whether to fire the pop up api or not.
}
推荐答案
In store()
return Redirect::route('clients.show, $id')->with( ['data' => $data] );
并在 show() 中用
Session::get('data');
这篇关于如何使用 Laravel 重定向发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 Laravel 重定向发送数据
基础教程推荐
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何替换eregi() 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
