I am a beginner in laravel. I wnat to have a change password form in my application. my view is like this:
<form action="{{ route("profile.changePassword") }}" method="post">
{{ csrf_field() }}
{{--{{ method_field('PUT') }}--}}
<div class="form-group">
<label for="old">Old password</label>
<input value="" type="password" name="old" class="form-control" id="old">
</div>
<div class="form-group">
<label for="new">New password</label>
<input value="" type="password" name="new" class="form-control" id="new">
</div>
<div class="form-group">
<label for="rep">Repeat new password</label>
<input value="" type="password" name="rep" class="form-control" id="rep">
</div>
<div class="text-center">
<button type="submit" class="btn btn-success">Update</button>
</div>
my controller is like this:
public function changePassword()
{
return view('profile.passwordReset');
}
public function resetPassword($request)
{
dd($request);
}
and my route is like this:
Route::group(['prefix' => 'panel'], function (){
Route::resource("profile", "ProfileController", ['except' => 'index']);
Route::get("/changepassword", "ProfileController@changePassword")->name('profile.changePassword')->middleware('auth');
Route::post("/resetPassword", "ProfileController@resetPassword")->name('profile.resetPassword')->middleware('auth');
});
But after I submit form I get an error:
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message
I change post("/resetPassword"... to any("/resetPassword"... and get a same error again.
profile.changePasswordwith a method of post. Your Route only hasgetforchangePassword. You should change it toRoute::post("/changepassword", ...- mankowitz