如何使用 Laravel 重定向发送数据 [英] How to send data using redirect with Laravel

查看:17
本文介绍了如何使用 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 重定向发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆