php 在 Laravel 5.1 中返回 URL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32826887/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Go back URL in Laravel 5.1
提问by Linus Odenring
How can I get the previous URL visited on the website in Laravel 5.1?
如何在 Laravel 5.1 中获取之前在网站上访问过的 URL?
In Laravel 4 I just needed to write it like below:
在 Laravel 4 中,我只需要像下面这样写:
{{ URL::previous() }}
回答by Mustafa Ehsan Alokozay
The cleanest way seems to be using the url()
helper:
最干净的方法似乎是使用url()
助手:
{{ url()->previous() }}
URL::previous()
works for me in my Laravel 5.1 project. Here is Laravel 5.1 docfor previous()
method, which is accessible through URL Facade.
URL::previous()
在我的 Laravel 5.1 项目中为我工作。这是Laravel 5.1 文档的previous()
方法,可通过URL Facade访问。
You can still try alternatives, in your views you can do:
您仍然可以尝试替代方案,在您的观点中,您可以执行以下操作:
{{ redirect()->getUrlGenerator()->previous() }}
or:
或者:
{{ redirect()->back()->getTargetUrl() }}