Level 2
@prince69 you can try this one
return view('path.to.view', compact('data'))->with('success', 'thank you');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want to return view with success message and data. I tried this way
return redirect()->route('some.route')->with(compact('data'))
->with('success', 'thank you');
I got success message in that view but variable is not passed. It shows an error "Undefined variable"
May be I tried with wrong way. What is the proper way to pass variable data with success message in return view??
Please or to participate in this conversation.