在 laravel breeze 项目中,可通过 `auth::user()->id` 获取当前认证用户的 id,并在 blade 模板(如 `navigation.blade.php`)中安全地传递给 `route()` 辅助函数,从而动态生成指向 `/profile/{id}` 的正确链接。
要在导航下拉菜单中为“Perfil”(个人资料)添加可点击的动态链接,关键在于正确构造命名路由的参数格式。你的路由定义为:
Route::get('/{id}', [ProfileController::class, 'show'])->name('profile');
这表示该路由接受一个名为 id 的必需路由参数(即隐式模型绑定或显式 ID),因此调用 route(‘profile’, $params) 时,必须以关联数组形式传入键值对,例如 [‘id’ => 123]。
✅ 正确写法(推荐):
Auth::user()->id])">
{{ __('Perfil') }}
⚠️ 常见错误及说明: