Home > Software design >  how to return to a specific page after form submit based on value laravel
how to return to a specific page after form submit based on value laravel

Time:04-13

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.

CodePudding user response:

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');
        }

  • Related