简体   繁体   中英

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();
        }

    }
}

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;

应该是Hash::make ,而不是HASH::make

in your controller file add in top

use Hash
// and use Hash::make instead of HASH::make
Hash::make(Input::get('currpassword'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM