Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to return to a specific page after form submit based on value laravel

i have a logic whereby on form submission i want to return to specific page based on a certain value the user choosed when submiting the form.the form works well but when i try to return it doesnt work.where might i be missing the point here.

 public function addtoorder(Request $request){
    $userid=Auth::user()->id;
     $addresses=Deliveryaddress::where('user_id',$userid)->first();
      if($request->isMethod('post')){
        $data=$request->all();
        $order = new Order();
        $order->name = Auth::user()->name;
        $order->phone =$addresses->phone;
        $order->county =$addresses->shipcharges->county;
        $order->town =$addresses->towns->town;
        $order->order_status="New Order";
        $order->payment_method = $request->payment_method;
        $order->user_id =$userid;
        $order->grand_total = Session::get('grand_total');
        $order->shipping_charges=$addresses->shipping_cost;
        $order->save();
        }
       if($data=="SKRILL"){
            return view('frontend.product.skrill');
        }elseif($data=="PAYPAL"){
            return view('frontend.product.paypal');
        }
     } 
  }

i have been able to save the data on the database but am unable to return to the specific pages.rather it return to blank page without any error,but it saves the data to the orders table perfectly.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I guess blank screen means that nothing was returned, because you are trying to check whether $data(which is array) is equal to some string.
My thoughts would be for you to try check string in your if statement.
Like this

  if($data['payment_method'] === "SKRILL"){
            return view('frontend.product.skrill');
        }elseif(data['payment_method'] === "PAYPAL"){
            return view('frontend.product.paypal');
        }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading