I am new to Laravel and I was reading some code and came across code to update
password. But I noticed that they weren't using PUT/PATCH method in the same as opposed to what I had seen in various other examples while writing CRUD such as
<form class="well" method="post" action="{{url('todo/'.$rec->id)}}">
{{csrf_field()}}
{{method_field("PUT")}}
But in this piece of code mentioned below there wasn't a mention of PUT/PATCH, why is it so? This is the controller code which uses Update()
public function updatePassword(Request $request) {
if ($request->isMethod('post')) {
$data = $request->all();
$user_email=Auth::user()->email;
$check_password = User::where(['email' => Auth::user()->email])->first();
$current_password = $data['current_pwd'];
if (Hash::check($current_password, $check_password->password)) {
$password = bcrypt($data['new_pwd']);
User::where('email', $user_email)->update(['password' => $password]);
return redirect('admin/settings')->with('flash_message_success', 'Password Updated Successfully');
}
else {
return redirect('admin/settings')->with('flash_message_error', 'Current Password Incorrect');
}
}
}
And this is the HTML Code:
<form class="form-horizontal" method="post" action="{{url('admin/update-pwd')}}" name="password_validate" id="password_validate" novalidate="novalidate">
<div class="control-group">{{csrf_field()}}
<label class="control-label">Current Password</label>
<div class="controls">
<input type="password" name="current_pwd" id="current_pwd" />
<span id="chkpwd"></span>
</div>
</div>