Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel get intended url

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.

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

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

like image 289
Adams.H Avatar asked Feb 01 '14 14:02

Adams.H


People also ask

How do I get the intended URL in laravel?

location = $intended_url; Alternatively, you may setup a View Composer so whenever the login view/form is displayed the intended url will be available in that view and you can do it using this: View::composer('login', function($view){ $intended_url = Session::get('url.

What is laravel redirect intended?

Official Laravel documentation describes it like this: The intended method on the redirector will redirect the user to the URL they were attempting to access before being intercepted by the authentication middleware.


1 Answers

In Laravel 5.7:

$url = redirect()->intended()->getTargetUrl();
like image 183
user580485 Avatar answered Oct 08 '22 08:10

user580485