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