在这里,我在忘记密码选项中获得了用户名,并且我正在尝试更改密码(暂时自定义方式 - 不要介意)
$UserData = Input::except(array('_token'));
$UserDetails = User::where('username', $UserData)->get()->toArray();
$user = User::find($UserDetails[0]['Id']);
$str = str_random(5);
$user->password = $str;
$user->save();
在模型内部,我使用
public function setpasswordAttribute($value)
{
$this->attributes['password'] = Hash::make(Input::get('password'));
}
因为我没有使用Hash::make(Input::get('password'))
.我猜拉拉维尔正在散列一些空值并存储。
我怎样才能用这样的东西$str
哈希我拥有的密码$this->attributes['password'] = $str;
?
(我的意思是只有$str应该散列)
你的模型是错误的。应该是这样的:
public function setPasswordAttribute($value)
{
$this->attributes['password'] = Hash::make($value);
}