本文整理汇总了PHP中Illuminate\Support\Facades\Hash::needsRehash方法的典型用法代码示例。如果您正苦于以下问题:PHP Hash::needsRehash方法的具体用法?PHP Hash::needsRehash怎么用?PHP Hash::needsRehash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Hash
的用法示例。
在下文中一共展示了Hash::needsRehash方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setAdminPassAttribute
/**
* 密码调整器
*
* @param $password
*/
public function setAdminPassAttribute($password)
{
if (Hash::needsRehash($password)) {
$password = Hash::make($password);
}
$this->attributes['admin_pass'] = $password;
}
示例2: saving
function saving($model)
{
///////////
// RULES //
///////////
$rules['name'] = ['required'];
$rules['password'] = ['required', 'min:8'];
$rules['gender'] = ['required', 'in:pria,wanita'];
$rules['dob'] = ['date', 'date_format:Y-m-d'];
$rules['email'] = ['email', 'unique:users,email,' . ($model->_id ? $model->_id : 'NULL') . ',_id'];
$rules['phone'] = ['string'];
//////////////
// VALIDATE //
//////////////
$data = $model->toArray();
$data['password'] = $model->password;
$validator = Validator::make($data, $rules);
if ($validator->fails()) {
$model->setErrors($validator->messages());
return false;
}
// Hash password
if (Hash::needsRehash($data['password'])) {
$model->password = Hash::make($data['password']);
}
}
示例3: saving
/**
* @param $user
* Hashes the users password if the developer wasn't already hashing it via an other method
* such as an attribute
* @return bool
*/
public function saving($user)
{
if (Hash::needsRehash($user->password)) {
$user->password = Hash::make($user->password);
}
return true;
}
示例4: setPasswordAttribute
/**
* Hash the users password.
*
* @param $value
*/
public function setPasswordAttribute($value)
{
if (Hash::needsRehash($value)) {
$this->attributes['password'] = bcrypt($value);
} else {
$this->attributes['password'] = $value;
}
}
示例5: setPasswordAttribute
public function setPasswordAttribute($password)
{
if (Hash::needsRehash($password)) {
$this->attributes['password'] = Hash::make($password);
} else {
$this->attributes['password'] = $password;
}
}
示例6: rehashPassword
/**
* Check if the user's password needs rehashing.
*/
public function rehashPassword($password)
{
if (!Hash::needsRehash($this->getAttributeFromArray('password'))) {
return;
}
if (!$this->confirmPassword($password)) {
return;
}
$this->setPasswordAttribute($password);
return $this->save();
}
示例7: getLogicButtonAttribute
/**
* @return string
*/
public function getLogicButtonAttribute()
{
// ajax route for creating new question
$logicurl = route('ajax.project.question.addlogic', [$this->project->id, $this->id]);
// get ajax urlhash for project
$hash = $this->urlhash;
if (isset($hash['logic'])) {
$urlhash = $hash['logic'];
} else {
$urlhash = '';
}
// check if rehash need or not
if (Hash::needsRehash($urlhash)) {
// rehash if urlhash column in project table empty or invalid
$hash['logic'] = Hash::make($logicurl);
// update project table in database with new or correct urlhash
$this->update(['urlhash' => $hash]);
}
$id = snake_case("{$this->qnum} -lgbtn");
$dataid = snake_case("{$this->qnum} -btn");
return '<a data-href="' . $logicurl . '" id=" ' . $id . '" data-modal="' . $dataid . '" href="#" class="btn btn-xs btn-primary ' . $dataid . '" data-toggle="modal" data-target="#logic" data-type="edit"><i class="fa fa-info" data-toggle="tooltip" data-placement="top" title="Add Logic" ></i></a>';
}
示例8: setPasswordAttribute
public function setPasswordAttribute($value)
{
if (strlen($value) < 3) {
return;
}
$this->attributes['password'] = Hash::needsRehash($value) ? bcrypt($value) : $value;
}