UserModel.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace app\common\model;
  3. use think\model\concern\SoftDelete;
  4. class UserModel extends BaseModel
  5. {
  6. // 设置表名
  7. protected $name = 'user';
  8. // 设置字段自动转换类型
  9. protected $type = [
  10. 'last_login_time' => 'timestamp:Y-m-d H:i:s',
  11. ];
  12. // 软删除
  13. use SoftDelete;
  14. protected $deleteTime = 'delete_time';
  15. protected $defaultSoftDelete = 0;
  16. // 常量
  17. const STATUS = [1 => '待审核', 2 => '已通过', 3 => '未通过', 4 => '禁用'];
  18. const GENDER = ['保密', '男', '女'];
  19. const AUTH = [1 => '待认证', 2 => '待审核', 3 => '审核拒绝', 4 => '审核通过'];
  20. const STATUS_WAIT = 1;
  21. const STATUS_PASS = 2;
  22. const STATUS_FAIL = 3;
  23. const STATUS_DISABLE = 4;
  24. const GENDER_MAN = 1;
  25. const GENDER_WOMAN = 2;
  26. const AUTH_UN = 1;
  27. const AUTH_WAIT = 2;
  28. const AUTH_REJECT = 3;
  29. const AUTH_PASS = 4;
  30. //允许修改
  31. const MOBILE_EDIT_ALLOW = ['realname', 'idcard', 'idcard_front_pic', 'idcard_back_pic', 'is_auth']; //手机端实名认证
  32. public function getStatusTextAttr($value, $data)
  33. {
  34. return self::STATUS[$data['status']];
  35. }
  36. public function getGenderTextAttr($value, $data)
  37. {
  38. return self::GENDER[$data['gender']];
  39. }
  40. public function getIsAuthTextAttr($value, $data)
  41. {
  42. return self::AUTH[$data['is_auth']];
  43. }
  44. }