我的代码如下所示:
{{ HTML::linkRoute('profile', 'My Profile', [Auth::user()->username]) }}
我想要的是指向的链接:
www.foo.com/profile/username
但我得到的实际链接是:
www.foo.com/profile?username
这是routes.php
Route::get('profile/{username}', ['as' => 'profile', 'uses' => 'Profile@getProfile']);
我正在使用laravel 4.1并且找不到任何解决方案。感谢。
答案 0 :(得分:0)
你已经在路由中定义了URL是profile / {username},什么是okey,所以在链接中你必须在第一个参数中设置用户名。
{{ HTML::linkRoute('profile/'.[Auth::user()->username], 'My Profile', }}
希望有所帮助
答案 1 :(得分:0)
我认为应该有效:
{{ HTML::linkRoute('profile', 'My profile', Auth::user()->username)}}
答案 2 :(得分:0)
使用link_to helper函数代替Html :: linkRoute:
{{ link_to('profile/'.$username, "Go to Profile") }}
答案 3 :(得分:0)
这适合我:
Route::get('profile/{username}', ['as' => 'profile', 'uses' => 'Profile@getProfile']);
{{ HTML::linkRoute('profile', 'My Profile', ['username' => Auth::user()->username]) }}