Operator.php 1019 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. use think\Session;
  5. class Operator extends Model
  6. {
  7. // 开启自动写入时间戳字段
  8. protected $autoWriteTimestamp = 'int';
  9. // 定义时间戳字段名
  10. protected $createTime = 'createtime';
  11. protected $updateTime = 'updatetime';
  12. public function authGroupAccess()
  13. {
  14. return $this->belongsTo('AuthGroupAccess', 'id','uid')->setEagerlyType(0);
  15. }
  16. public function adminExtend()
  17. {
  18. return $this->belongsTo('AdminExtend', 'id','admin_id')->setEagerlyType(0);
  19. }
  20. /**
  21. * 重置用户密码
  22. * @author baiyouwen
  23. */
  24. public function resetPassword($uid, $NewPassword)
  25. {
  26. $passwd = $this->encryptPassword($NewPassword);
  27. $ret = $this->where(['id' => $uid])->update(['password' => $passwd]);
  28. return $ret;
  29. }
  30. // 密码加密
  31. protected function encryptPassword($password, $salt = '', $encrypt = 'md5')
  32. {
  33. return $encrypt($password . $salt);
  34. }
  35. }