Hilbert
2 months ago
346
7
Laravel

How can I return a value with redirect back

Posted 2 months ago by Hilbert

After a form submit I am calling result method and from there I am running a query $calculations = Transaction::where('product_name',$request->product)->where('real_date',$request->date)->get();

Now I want to return the $calculations in the same blade file where the form was, where there is a table I want to populate with this data. I am trying this but not working.

return back()->with(['calculations'=>$calculations]);

or

return back()->with(compact('calculations'));

the data returns empty when I dd in the blade file.

Please sign in or create an account to participate in this conversation.