I need update some record and this is form action in my blade
<form class="form-vertical" role="form" method="post" action="/projects/{{ $project->id }}/collaborators/{{ $collaborator->user()->first()->id }}">
controller
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');
}
routes
Route::put('projects/{projects}/collaborators/{id}',['uses'=>'ProjectCollaboratorsController@update',]);
when click update button generate following error
MethodNotAllowedHttpException in RouteCollection.php line 218:
how can solve this
As @Tiger mentioned in comment,
In your route you have defined put method and your form is using post method you should have to add hidden input in your form.
Add <input type="hidden" name="_method" value="PUT">
after your opening form
tag. Like below:
<form class="form-vertical" role="form" method="post" action="/projects/{{ $project->id }}/collaborators/{{ $collaborator->user()->first()->id }}"
<input type="hidden" name="_method" value="PUT">