Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Brian van Vlymen
12,637 PointsWhich one is property to use Laravel "<a herf" those are couple different ways that I discovery
I have noticed those are different way to prefer to use for "a herf" that I wrote myself on the note.
<a href="{{{ action('AdminController@getIndex') }}}">HOME</a>
<p>{{ link_to_route('comments.show', 'Title of the Post', array($comment->id)) }}</p>
<p>{{link_to_action('PostController@show','Read Blog', array($post->id))}}</p>
<p><a href="{{ URL::action('post-show', $post->slug)}}">Read more</a></p>
<li>{{ HTML::link('posts', 'Add Post') }}</li>
Are those lists are nothing wrong with it because depends on what they prefer to use it?
if I rather to be stronger PHP language would be
<a href="{{{ action('AdminController@getIndex') }}}">HOME</a>
because its almost similarly to
<a href="<?php ../any_file/any_file ?> ">HOME</a>
so that way I can easier to remember?
1 Answer
thomascawthorn
22,986 PointsThe most robust way to manage links is probably through named routes:
<?php
link_to_route('comments.show', 'Title of the Post', array($comment->id));
If you ever wanted to change action('AdminController@getIndex') to action('AdminController@getHome'), you would have to change every instance of getIndex to getHome - this is not good! If you had a named route, you would just have to change the routes.php file to update your entire applicaiton.