未找到 Laravel 类“HASH”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21477684/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel Class 'HASH' not found
提问by DolDurma
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();
}
}
}
回答by Chameera M Perera
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;
回答by chrona
It should be Hash::make
, not HASH::make
.
应该是Hash::make
,不是HASH::make
。
回答by ImBhavin95
in your controller file add in top
在您的控制器文件中添加顶部
use Hash
// and use Hash::make instead of HASH::make
Hash::make(Input::get('currpassword'))