How to check current password using hash check in Laravel?
Sometimes we are working on change password function at that time we require to check with current password in laravel 6, laravel 7, laravel 8 and laravel 9 app. If current password should be match otherwise return error with "your old password is wrong".
I mean we have one form with three input field like as bellow:
1)current password
2)new password
3)confirm new password
When it will submit form we have to check current password match with store database table password. So, laravel store hash password, that way we can't check directly equal to condition, But Laravel provide Hash facade, Hash::check() method will help you to do this task.
You can see bellow simple example method:
Example:
public function changePassword(Request $request)
{
$input = $request->all();
$user = User::find(auth()->user()->id);
if(!Hash::check($input['current_password'], $user->password)){
dd('Return error with current passowrd is not match.');
}else{
dd('Write here your update password code');
}
}
It can help you...

Hardik Savani
I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Laravel Model Events Tutorial
- Laravel Livewire Add or Remove Dynamically Input Fields Example
- Laravel 8 Multi Auth (Authentication) Tutorial
- Laravel 8 Install Vue JS Example Tutorial
- Laravel Eloquent orderByRaw() Query Example
- Laravel Livewire CRUD Application Tutorial
- How to create authentication(login and registration) in Laravel 5.2?
- Laravel 5.2 multi auth example using Auth guard from scratch
- Laravel Google OAuth authentication using Socialite Package
- Laravel Facebook authentication using Socialite Package
- Laravel 5.2 API using JWT authentication tutorial from scratch example