2
我需要更新一些记录,这是形式的行动,我的刀片MethodNotAllowedHttpException而Laravel提交表单5.2
<form class="form-vertical" role="form" method="post" action="/projects/{{ $project->id }}/collaborators/{{ $collaborator->user()->first()->id }}">
控制器
public function update(Request $request, $projectId, $collaboratorId)
{
$this->validate($request, [
'status' => 'required',
]);
DB::table('permissions')
->where('project_id', $projectId)
->where('collaborator_id', $collaboratorId)
->update(['status' => $request->input('status')]);
return redirect()->back()->with('info','Your Permission has been updated successfully');
}
路线
Route::put('projects/{projects}/collaborators/{id}',['uses'=>'[email protected]',]);
当点击更新按钮产生以下错误
MethodNotAllowedHttpException in RouteCollection.php line 218:
怎么解决这个
在你的路线,你已经定义了'put'方法和表单使用'POST'方法,你应该在你的表单中添加隐藏的输入。 – Tiger