我开发了一个 API 来在页面加载时显示弹出消息。
并非所有页面都使用弹出式 API。例如,如果用户转到 show($id)
页面,则不需要触发弹出式 API。但在某些特殊情况下,我需要触发弹出窗口。
这是我的代码,**此代码只是为了说明我的观点,而不是实际的工作代码**
public function store(){
validating the input
saving them
$id = get the id
return Redirect::route('clients.show, $id')
}
在显示功能中我这样做:
public function show($id){
$client =Client::find($id)
return View::make('clients.profife')->with(array(
'data' => $client
))
我的问题
有没有办法让我可以将数据从 store
函数发送到 show
函数 使用 Redirect::route ?然后在 show
函数中,我检查此 show
函数是否已发送此数据,然后我决定是否触发弹出 api 或不是。
}
最佳答案
在商店中()
return Redirect::route('clients.show, $id')->with( ['data' => $data] );
并在 show()
中用
Session::get('data');
关于php - 如何使用 Laravel 重定向发送数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25078452/