更新时间:2022-12-10 08:08:55
终于,2 天后我找到了我的答案,我想在这里为每个可能遇到同样问题的人提供我的答案.
Finally, after 2 days I found my answer and I would like to provide my answer here for everyone who maybe has the same problem.
为了使路由绑定起作用,您应该让类型提示的变量名称与路由段名称匹配,如文档要求:
For route binding to work you should have type-hinted variable names match a route segment name, as the doc required :
例如我的编辑方法
这里是我要编辑的路由 URI
Here my route URI for edit
admin/file/{file}/edit
如您所见,有 {file}
参数或您调用的任何内容现在只需要在函数参数中准确地写$file
As you can see there is {file}
parameter or anything you call
now just need write exactly $file
in function parameter
public function edit(Files $file)
{
return view('admin.edit',compact('file'));
}