In Django, I can do this:
<a href="{% url 'account_login' %}">Account Link</a>
which would give me domain/account/login
where I have that URL named in my urls.py
url(r'^account/login/$', views.Login.as_view(), name='account_login'),
I want to do something similar in Laravel 5.2
I currently have something like this:
Route::get('/survey/new', ['as' => 'new.survey', 'uses' => 'SurveyController@new_survey']);
How do I use in my template, plus passing in parameters?
I came across this: https://laravel.com/docs/5.1/helpers, but it was just a piece of a white page without relevant content of how to actually use it.
You can use the
route()
helper, documented here.If you include
laravelcollective/html
you could uselink_to_route()
. This was originally part of the core but removed in Laravel 5. It's explained hereThe Laravel Collective have documented the aforementioned helper here. The function prototype is as follows
If for example you wanted to use parameters, it accepts an array of key value pairs which correspond to the named segments in your route URI.
For example, if you had a route
You can generate a link to this route using the following in the parameters.
A full example, echoing markup containing an anchor to the named route.