缺少[Route:projects.edit] [URI:projects/{project}/edit] Laravel 6.3所需的参数 [英] Missing required parameters for [Route: projects.edit] [URI: projects/{project}/edit] Laravel 6.3
问题描述
此错误使我无法前进.有谁能解决缺少必填参数错误的问题?我有一个非常简单的CRUD设置,它会在Controller的"edit"方法中引发此错误.当请求转发到编辑视图时,就会发生这种情况.
This error has blocked me way forward. Does anyone have a solution to the Missing required parameters error? I have a very simple CRUD setup which throws this error in the Controller 'edit' method. This happens when the request is forwarded to the edit view.
错误:
```Facade\Ignition\Exceptions\ViewException
Missing required parameters for [Route: projects.edit] [URI:
projects/{project}/edit]. (View:
T:\estie\resources\views\frontend\layouts\homeapp.blade.php)```
路由定义为:
```Route::resource('projects','ProjectsController');```
控制器编辑方法:
```public function edit(Project $project)
{
return view('projects.edit') ->with('project',$project);
}```
这是我的index.blade.php的一部分,它扩展了homeapp.blade.php:
<td align="center">
<a href="{{ route('projects.edit', ['project' => $project]) }}">EDIT</a>
</td>
请感激任何帮助.
推荐答案
当您尝试使用route
函数获取路由的URL而没有提供必需的参数时,会引发此错误.
This error is thrown when you try to get the URL of a route using the route
function without providing a required parameter.
在homeapp.blade.php
中查找route('projects.edit')
调用,并将项目添加为参数:route('projects.edit', ['project' => $project])
Look for the route('projects.edit')
call in your homeapp.blade.php
and add the project as a parameter: route('projects.edit', ['project' => $project])
这篇关于缺少[Route:projects.edit] [URI:projects/{project}/edit] Laravel 6.3所需的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!