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?
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()) }}
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.