callen5914's avatar

URL Helper

So how do these work anyways?

Here's what I got:


<li><a href="{{ url('/profile', $params) }}">My Profile</a></li>

I've also tried using $id to get a route like profile/{id}

But I am still getting an undefined variable

0 likes
3 replies
callen5914's avatar

This was found to work! But I think there is a better way no?

<li><a href="{{ action('ProfileController@show', Auth::user()->id) }}">My Profile</a></li>

1 like
mstnorris's avatar

If you are using Laravel 5, this is what you might be looking for:

TLDR; You'll need to include the package found at the URL below.

http://laravelcollective.com/docs/5.0/html - Installation instructions

http://laravelcollective.com/docs/5.0/html#generating-urls - Usage instructions


{!! link_to_route(name : string, [title = null], [parameters : array = array()], [attributes : array = array()]) !!}

or

{!! link_to_action(action : string, [title = null], [parameters : array = array()], [attributes : array = array()]) !!}

or

{!! link_to(url : string, [title = null], [attributes : array = array()], [secure : bool|null = null]) !!}
bashy's avatar

Needs to be an array for the params?

<li><a href="{{ url('/profile', ['id' => $profile_id]) }}">My Profile</a></li>
1 like

Please or to participate in this conversation.