Laravel - Method link_to_route does not exist

一笑奈何 提交于 2019-12-22 16:35:03

问题


I get an error when i use HTML::link_to_route, but not when i use HTML::Link Why?

{{ HTML::decode(HTML::link_to_route('homepage', '<div class="logo"></div>')) }}

The same for:

{{ HTML::link_to_route('about', 'WHAT IS IT') }}

The error:

BadMethodCallException
Method link_to_route does not exist.

Version 4.0.x


回答1:


Fixed it, it seems that the documentation is really out-dated, or that laravel 4.0 is just really new ;)

replaced "link_to_route" with "linkRoute". Found it by looking into the vendor files.




回答2:


Just FYI, or next searcher

For the latest Release (4.1) the text will be encoded itself. to get the link you have to specify the link manually like this

 <a href="{{ URL::route('homepage') }}"><i class="fa fa-pencil "></i></a>



回答3:


It's must easier to use linkRoute.

Example: {{ HTML::linkRoute('name-of-route', 'Go to my route') }}




回答4:


If you wanted to use the old way http://laravelcollective.com/docs/5.0/html

However this seems to be the new way

string linkRoute(string $name, string $title = null, array $parameters = array(), array $attributes = array())

http://laravel.com/api/5.0/Illuminate/Html/HtmlBuilder.html#method_link

See usage http://laravel-recipes.com/recipes/190/generating-a-html-link-to-a-named-route



来源:https://stackoverflow.com/questions/16845540/laravel-method-link-to-route-does-not-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!