Redirect laravel 5.2使用参数重定向到url

Redirect laravel 5.2使用参数重定向到url,redirect,laravel-5.2,Redirect,Laravel 5.2,大家好:)我开发了一个表单,可以从用户那里获取数据并使用AmazonAPI进行搜索,然后我想在另一个页面中显示结果,我只是用我的结果参数重定向到另一个页面,但我无法在新页面中访问我的参数,这是我的代码 $search = new Search(); $search->setCategory('Books'); $search->setKeywords($searchItem); $sear

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

            $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);
请帮助我解决我的问题,谢谢:)

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

{{ session('response') }}
或:

请注意,随
with()
发送的数据是闪存数据,这意味着它将在页面刷新或导航时被删除

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

redirect('/searchItem?'. http_build_query( $data ));
如果在重定向中使用
with()
,则可以使用以下方法访问
$data
数组:

{{ session('response') }}
或:

请注意,随
with()
发送的数据是闪存数据,这意味着它将在页面刷新或导航时被删除

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

redirect('/searchItem?'. http_build_query( $data ));

有许多重定向到刀片文件或函数的方法。你可以试试这个:-

Redirect to blade file use this method:-
return view('your viewfile')->with(compact('data'));
                   or
Redirect to method in controller use this technique:-
use Illuminate\Support\Facades\Redirect; // Add this in top of controller
return Redirect::to('/searchItem')->with(compact('data'));

希望对您有所帮助

有很多重定向到刀片文件或函数的方法。你可以试试这个:-

Redirect to blade file use this method:-
return view('your viewfile')->with(compact('data'));
                   or
Redirect to method in controller use this technique:-
use Illuminate\Support\Facades\Redirect; // Add this in top of controller
return Redirect::to('/searchItem')->with(compact('data'));
希望能有帮助