我希望我的用户通过URL访问其配置文件编辑页面:/profile/slug/edit
,其中slug表示$user->slug
。 我web.php
contans:用户路由Laravel 5.4
Route::group(['middleware' => 'auth'], function() {
Route::get('/profile/{slug}', [
'uses' => '[email protected]',
'as' => 'profile'
]);
Route::get('/profile/{slug}/edit', [
'uses' => '[email protected]',
'as' => 'profile.edit'
]);
如何调用从视图[email protected]
,如何正确传递参数?尝试:
<a href="{{route('profile', ['slug'=> Auth::user()->slug],'edit')}}">
Edit your profile</a>
你的路线应该有profile.edit而不是只有配置文件。并将配置文件作为路由功能的第三个参数移除。 – Timo002
是否可以简化我的代码?并缩短我的代码?我前缀',但如何处理'slu'',我必须通过它在我的每一个'路线()'? – pvaitonis