laravel 5.2 重定向到带有参数的 url

Ami*_*adi 1 redirect laravel-5.2

大家好:) 我开发了从用户那里获取数据并使用 amazon api 搜索的表单,然后我想在另一个页面中显示结果,我只是使用我的结果参数重定向到另一个页面,但我无法在新页面中访问我的参数,这是我的代码

            $search = new Search();
            $search->setCategory('Books');
            $search->setKeywords($searchItem);
            $search->setPage(2);
            $search->setResponseGroup(array('Large'));

            $response = $apaiIO->runOperation($search);


            $totalResult = $response['Items']['TotalResults'];
            $totalPage = $response['Items']['TotalPages'];

            $data = array(
                'response' => $response,
                'totalResult' => $totalResult,
                'totalPage' => $totalPage,
                'uni' => $unies,
            );


            return redirect('/searchItem')->with($data);
Run Code Online (Sandbox Code Playgroud)

请帮我解决我的问题,谢谢:)

Nir*_*hah 5

如果with()在重定向中使用,则可以$data使用以下方法访问数组:

{{ session('response') }}
Run Code Online (Sandbox Code Playgroud)

或者:

Session::get('response')
Run Code Online (Sandbox Code Playgroud)

注意发送的数据with()是flash数据,这意味着它会在页面刷新或导航时被删除。

如果要将数组添加到 URL,可以执行以下操作:

redirect('/searchItem?'. http_build_query( $data ));
Run Code Online (Sandbox Code Playgroud)