Reputation: 231
hi everyone :) i develop the form that get data from users and search with amazon api then i want to show results in another page , i just redirect to another page with my result parameters , but i cannot access to my parameters in new page , here is my code
$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);
please help me to solve my problem, thank you :)
Upvotes: 1
Views: 4934
Reputation: 4248
There are many methods of redirect to blade file or function. You may try this :-
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'));
Hope it helps
Upvotes: 0
Reputation: 15457
If you use with()
in your redirect, you can access the $data
array using:
{{ session('response') }}
or:
Session::get('response')
Note that the data sent with with()
is flash data, which means it will be deleted on page refresh or navigation.
If you want to add the array to the URL, you can do:
redirect('/searchItem?'. http_build_query( $data ));
Upvotes: 5