1

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 :)

2 Answers 2

5

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 ));
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.