Laravel得到了想要的网址 [英] Laravel get intended url

查看:86
本文介绍了Laravel得到了想要的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用常见的httpRequest登录,因此我可以使用 Redirect :: intention(); 在用户进入登录页面之前引导用户访问网址。一切正常。

I use a common httpRequest to login, so I could use Redirect::intended(); to lead the user to a url before them being lead to the login page. That all works well.

现在我已经更改登录到ajax请求我现在只能在javascript中重定向url。所以我要将预期的网址传递到前端,然后执行 window.location = url

Now I've changed login to ajax request I can only redirect the url in javascript now. So I've to pass the intended url to front end then do the window.location=url

问题是我无法获得意图/原始我的网址。任何一种laravel专家可以帮助我吗?

The problem is I can't get the intended/original url. Can any kind laravel expert help me out ?

推荐答案

在你的控制器动作中使用:

In your controller action use:

$ url =重定向::打算(...) - > getTargetUrl();

(其中 ... 是后备网址)

然后在JSON响应中返回它,并使用 window.location 或其他进行重定向。

Then return it in the JSON response, and use window.location or other to do the redirect.

这篇关于Laravel得到了想要的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆