Laravel Change Password with Current Password Validation Example

Laravel updates a new password using the old password in laravel. These tutorials demonstrate to you, how you can easily update the new password with validation old password.
Here you will learn, how to validate input fields like old password, new password and confirm password using laravel validation rules.
Laravel change password old password validation
In this example, this below function accepts three parameters like old password, new password and confirm password. If you entered the wrong password this function returns back with your laravel route.
public function updatePassword(Request $request)
{
$this->validate($request, [
'old_password' => 'required',
'new_password' => 'required|min:6',
'confirm_password' => 'required|same:new_password',
]);
$data = $request->all();
$user = User::find(auth()->user()->id);
if(!\Hash::check($data['old_password'], $user->password)){
return back()->with('error','You have entered wrong password');
}else{
here you will write password update code
}
}
Conclusion
Here, you have learned how you can change the password with your old password validation.
Recommended Laravel Tutorials
Recommended:-Laravel PHP Artisan Serve Not Working
Recommended:-Laravel Get Record Last Week, Month, 15 Days, Year
Recommended:-How to Set or Increase Session Lifetime in Laravel
Recommended:-Laravel where Day, Date, Month, Year, Time, Column
Recommended:-Laravel Try Catch
Recommended:-Laravel Eloquent whereRaw Query Example
Recommended:-How to Get Random Records in Laravel
Recommended:-Laravel InsertOrIgnore Example
Recommended:-Laravel whereIn, whereNotIn With SubQuery Example
Recommended:-Laravel Eloquent withSum() and withCount() Tutorial
Recommended:-Laravel Where Null and Where Not Null Query
Recommended:-Laravel Eloquent firstWhere() Example
Recommended:-Laravel Group by Example
Recommended:-Laravel WhereHas Eloquent Example
Recommended:-Laravel Eloquent selectRaw Query Tutorial
Recommended:-Laravel Order by Example
Recommended:-Laravel orderByRaw() Query Example
Recommended:-Fetch Single Row Data from Database in Laravel
Recommended:-Laravel Disable Created_at and Updated_at timestamps
Recommended:-Laravel OneSignal Web Push Notification Example
Recommended:-Get Last 3, 6, 12 Months Data in Laravel
Recommended:-Laravel Download File From AWS s3 Bucket
Recommended:-Laravel Override Login Method
Recommended:-Laravel Connect Remote Database using SSH Tunnel
Recommended:-How to fix Error: laravel.log could not be opened?
Recommended:-Laravel One to One Relationship Example
Recommended:-Laravel One to Many Relationship Example
Recommended:-Laravel Many to Many Relationship Example
Recommended:-Laravel One to Many Polymorphic Relationship Example
Recommended:-How to Create Custom Route File in Laravel App
Recommended:-Laravel Chunk Eloquent Method Example
Recommended:-Laravel Eloquent whereTime Query Example
Recommended:-Laravel whereExists and whereNotExists Query Example
Recommended:-Laravel whereLike Query Example
Recommended:-Laravel Joins Example Tutorial
Recommended:-How to Get Current Route Name in Laravel
Recommended:-How to Remove Public From URL in Laravel
Recommended:-Laravel Query Scope Example Tutorial



