Danish Tahir
Danish Tahir

Reputation: 117

How to get a value in controller from get method and return it back to another view?

The problem looks basic but it is really painful! I'm using get method and getting value in controller and I want the same value to return in another view. How can I do that??? Please help!!! This is my function from controller:

public function guest(){
      if (Input::get('Cash On Delivery')){
        $get = Input::get('Cash On Delivery');
        return Redirect::to('guest/guestview/'.$get);
      }

Upvotes: 1

Views: 594

Answers (2)

Emeka Mbah
Emeka Mbah

Reputation: 17545

Well, with regards to your answer, using $_REQUEST directly is not Laravel's way of doing things :(

I believe this is better

public function guest(Request $request)
{
    if ($request->payment_method == ('Cash On Delivery'))
    {
         return view('guest/guestview', ['guest'=>$request->payment_method]);
    }
}

Upvotes: 1

Danish Tahir
Danish Tahir

Reputation: 117

Ok Guys, I figured it out, Just do this below.

public function guest(Request $request){
      if ($request->payment_method == ('Cash On Delivery')){
        $get = $_REQUEST['payment_method'];
        return view('guest/guestview', compact('get'));
      }

Upvotes: 0

Related Questions