Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Class 'HASH' not found

after validate rules i want to check current enterd password width saved hash password on database.and i'm using this below code, but i get error :

Error Code:

Symfony \ Component \ Debug \ Exception \ FatalErrorException

Class 'HASH' not found

my Controller Action:

public function update($id)
{
    $rules = array(
        'name'       => 'required|alpha',
        'family'     => 'required',
        'email'      => 'required',
        'password'   => 'required|confirmed',
        'password_confirmation'=>'required',
    );

    $validator = Validator::make(Input::all(), $rules);

    if ($validator->fails()) {
        return Redirect::to('/admin/profile')
            ->withErrors($validator)
            ->withInput();
    } 
    else 
    {
        $currentPassword = User::find($id);
        if ( $currentPassword == HASH::make(Input::get('currpassword')) ){
            return Redirect::route('/admin/profile')
                ->with('message', 'Password Match Error')
                ->withInput();
        }

    }
}
like image 635
DolDurma Avatar asked Nov 27 '22 13:11

DolDurma


2 Answers

I also faced this issue. But finally found the fix for the issue. Please include the following path on top of your code file. Then it may fix.

use Illuminate\Support\Facades\Hash;
like image 106
Chameera M Perera Avatar answered Dec 07 '22 00:12

Chameera M Perera


It should be Hash::make, not HASH::make.

like image 44
chrona Avatar answered Dec 07 '22 02:12

chrona