Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aleksov's avatar

Is possible to redirect back with variable ?

Hi I have serious problem ...

I have form submit and store function in controller but also at the same frontend blade file I need order_id to trigger STripe payment ... so I need to store data and then send back order_id ... so I try:


public function store(Requests\OrderRequest $request)
    {
        $order = new Order($request->all());

        $order->save();
        $order_id = $order->id;
        Cart::store($order_id);


   Alert::success('Order has beed added!','Good job!')->persistent("Close");
 Redirect::back()->with($order_id);       
   
          }

but when I run code order is succesfull added to database but I dont get back $order_id variable ...

Is that possible in Laravel 5.1?

0 likes
2 replies
InaniELHoussain's avatar
Level 32
Redirect::back()->with('key', $order_id);

and in the view use the $key variable

Please or to participate in this conversation.