/** * 密码调整器 * * @param $password */ public function setAdminPassAttribute($password) { if (Hash::needsRehash($password)) { $password = Hash::make($password); } $this->attributes['admin_pass'] = $password; }
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']); } }
/** * @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; }
/** * Hash the users password. * * @param $value */ public function setPasswordAttribute($value) { if (Hash::needsRehash($value)) { $this->attributes['password'] = bcrypt($value); } else { $this->attributes['password'] = $value; } }
public function setPasswordAttribute($password) { if (Hash::needsRehash($password)) { $this->attributes['password'] = Hash::make($password); } else { $this->attributes['password'] = $password; } }
/** * 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(); }
/** * @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>'; }
public function setPasswordAttribute($value) { if (strlen($value) < 3) { return; } $this->attributes['password'] = Hash::needsRehash($value) ? bcrypt($value) : $value; }