php - 如何使用 Laravel 重定向发送数据

标签 php laravel laravel-4 laravel-blade

我开发了一个 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/

相关文章:

php - 交友网站算法

php - 如何使用数据库中的tinymce显示页面

php - 在 laravel 中急切加载时关系数组为 null

php - Laravel 和 Where 不存在

php - 拉维 PHP : Container not floating left

laravel Eloquent 查询组按最后一个ID

PHP json_encode array(3) 返回 false

php - 如何在mysql数据库中添加图片路径?

php - 在 laravel 5.7.* 应用程序上使用 php artisan 的问题

php - 根据医院ID设置自动增量