How to redirect to previous page in laravel5.2 like URI Referrer in php.
I've tried $request->url(); but it gets the current url.
I've a form and list pages.There are many lists that redirects to form.but I want to go to that specific page after submit.
For Ex:There are a Project and Client list. If I go to form from project then it should go to project and if I go to form from client list It should go to client list page after submitting a form.
你应该使用return redirect()->back();
在您的模板文件中,您可以使用:
{{ url()->previous() }}
你有一个全局返回函数:
return back();
Thank You for answers. I've got it now.
set the hidden variable in blade to get previous page url using
{{ Form::hidden('url',URL::previous()) }}
after that get it by $request->input('url');
in controller,Then redirect it.
return redirect($url)->with('success', 'Data saved successfully!');
To redirect from template You should use
{{ url()->previous() }}
To redirect from the controller you should use
return redirect()->back();
or Just
return back();
you should this methods:
return calling controller:
return redirect()->action('classcontroller@fuction');
return calling url:
return redirect('home/dashboard');
You can redirect back to previous page on Laravel Blade using
{{ url()->previous() }}
Example below:
<a href="{{ url()->previous() }}">
<i class="fa fa-arrow-circle-o-left"></i>
<span>Back</span>
</a>
As the description of your problem, the simple solution is, you have to use the below code in the controller,
return back();
or,
return redirect()->back();
If you want to get the link from where you came from, You can apply the following code in the blade template,
{{ url()->previous() }}
You should use a global function
return back();
try this
<a class="btn btn-primary" href="{{ URL::previous() }}">Back</a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.