Hi Douglas,
I'm not sure why you are adding an extra step to the user after posting the data, sending him to "pages.preview_ad" and then adding a "Go Back" link. In my opinion it is an unnecessary step but don't know the whole logic of your app so don't judge.
$previewData = Preview::create(["title"=>$request->title]);
That's gonna save and return the data you need.
$previewData = Preview::latest('id')->first();
return view('the previous view')->with('previewData', $previewData);
Alternatively you could add the id of your actual preview to the link(in the view) and use it as a variable to find the right Preview when going back, you would need to change your route to:
Route::get('/Create_ad/go_back/{id}', 'PreviewsController@go_back');
and go_back method to:
public function go_back($id=null)
{
$previewData = Preview::find($id);
return view('your preview view')->with($previewData);
}
You also need to make sure your checking if previewData is not empty on the view and then filling each input. Take a look at Form::Model if you have a chance, it'd be very useful for this matter.
That isn't quite what i mean, i want to go back to the page before the preview (only if my link is used), where the form is posted. On that page i want to have all inputs to be filled in as before the form was submitted. It works if i run the line of code here inside the store method, but not when i run it in "go_back" method.
return back()->withInput();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community