Question

I need to get the route in my view for redirecting.

Right now I'm doing this:
Laravel 4 - Get Current Route Name on Hidden Input to use for search

{{ Form::hidden('route', Route::current()->getUri()) }}  

Problem is, it looks like this when I get on a page with an id:

<input name="route" type="hidden" value="recipes/details/{id}">  

How can I parse the {id} variable?

Was it helpful?

Solution

You should use:

Request::url();

Instead of Route::current()->getUri(), but it's not proper way to redirect from the View, you should redirect from your Controller instead.

It should be in your case (for full url):

 // 'http://example.com/recipes/details/10'
{{ Form::hidden('route', Request::url()) }}

or use this (only for path):

 // 'recipes/details/10'
{{ Form::hidden('route', Request::path()) }}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top