Account Link which would give me d...">

Using a Named URL in a blade template

In Django, I can do this:

<a href="{% url 'account_login' %}">Account Link</a>

which would give me domain/account/loginwhere I have the url specified in my urls.py

url(r'^account/login/$', views.Login.as_view(), name='account_login'),

I want to do something like this in Laravel 5.2

I currently have something like this:

Route::get('/survey/new', ['as' => 'new.survey', 'uses' => 'SurveyController@new_survey']);

How to use in my template and also pass parameters?

I stumbled upon this: https://laravel.com/docs/5.1/helpers , but it was just a fragment of a white page without the corresponding content of how to actually use it.

+4
source share
1 answer

You can use the assistant route()registered here .

<a href="{{ route('new.survey') }}">My Link</a>

laravelcollective/html, link_to_route(). , Laravel 5.

{!! link_to_route('new.survey', 'My Link') !!}

Laravel .

link_to_route($routeName, $title = null, $parameters = [], $attributes = []);

, , , , URI .

,

Route::get('surveys/{id}', 'SurveyController@details')->name('detail.survey');

, .

['id' => $id]

, -, .

{!! link_to_route('new.survey', 'My Link', ['id' => $id]) !!}
+15

Source: https://habr.com/ru/post/1650591/


All Articles