您好,我正在尝试从刀片服务器(welcome.blade.php)设置URL(href)以登录用户的用户个人资料。
我的网址必须是这样-> sample.com/profile/24
那里,有24个已登录用户的用户ID
<a href="{{URL('/profile/{{ Auth::user()->id }}')}}" class="btn btn-primary">profile</a>
但是当我运行代码时,它给了我以下异常,
Facade \ Ignition \ Exceptions \ ViewException语法错误,意外的'}',期望的是')'
无需在{{}}
内再次使用{{}}
更改
<a href="{{URL('/profile/{{ Auth::user()->id }}')}}" class="btn btn-primary">profile</a>
to
<a href="{{URL('/profile/'.Auth::user()->id)}}" class="btn btn-primary">profile</a>
或者,如果您有设置路线来显示用户个人资料,也可以这样做
<a href="{{route('users.show', Auth::user()->id)}}" class="btn btn-primary">profile</a>
那么您的路线将是这样的
Route::get('profile/{user}', 'UsersController@show')->name('users.show');