Laravel 错误:缺少路由所需的参数
2022-08-30 13:55:48
我一直收到此错误
ErrorException in UrlGenerationException.php line 17:
当任何页面加载并且我登录时。
这是我的导航的样子
@if(Auth::guest())
<li><a href="{{ url('/login') }}">Log In</a></li>
<li><a href="{{ url('/register') }}">Sign Up</a></li>
@else
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ Auth::user()->nickname }}<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{{ route('user.profile') }}">Profile</a></li>
<li><a href="{{ route('user.settings') }}">Settings</a></li>
<li><a href="{{ url('/logout') }}">Log Out</a></li>
</ul>
</li>
@endif
我遇到的问题是{{route('user.profile') }} 不起作用??
当我点击链接是 www.mydomain.com/User/SCRATK/profile 工作正常,但由于此错误,页面无法加载??
Missing required parameters for [Route: user.profile] [URI: user/{nickname}/profile].
这是我的路线文件
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::get('/', ['as' => 'home', 'uses' => 'BaseController@index']);
Route::group(['namespace' => 'User', 'prefix' => 'user'], function(){
Route::get('{nickname}/settings', ['as' => 'user.settings', 'uses' => 'SettingsController@index']);
Route::get('{nickname}/profile', ['as' => 'user.profile', 'uses' => 'ProfileController@index']);
});
});