路线
Route::get('/dashboard/view-sub-project/{pid}/{sid}', 'SubProjectController@view')->name('sub-project.view')->middleware('auth');
查看
<a href="{{ route('sub-project.view', request()->route()->parameters['id'] . '/' . $update->id) }}" class="btn btn-primary project-view">View</a>
var的值
request()->route()->parameters['id']
是2
$update->id
是1
我已经在web.php和视图上正确定义了路由器,但仍然会抛出错误
缺少[Route:sub-project.view]所需的参数[URI: 仪表板/视图子项目/ {PID} / {SID}]。 (视图: /var/www/html/groot-server/resources/views/project/view.blade.php)
我试图像这样改变我的路由器
Route::get('/dashboard/view-sub-project/{pid}{sid}', 'SubProjectController@view')->name('sub-project.view')->middleware('auth');
仍然有同样的错误。
答案 0 :(得分:3)
尝试在数组中添加参数。
Route::get('/dashboard/view-sub-project/{pid}/{sid}','SubProjectController@view')
->name('sub-project.view')
->middleware('auth');
<a href="{{ route('sub-project.view',
[
'pid' => request()->route()->parameters['id'],
'sid' => $update->id
]
) }}" class="btn btn-primary project-view">
View
</a>
希望这有帮助。