UserModel.php 959 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\common\model;
  3. use think\model\concern\SoftDelete;
  4. class UserModel extends BaseModel
  5. {
  6. // 设置表名
  7. protected $table = '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 STATUS_WAIT = 1;
  20. const STATUS_PASS = 2;
  21. const STATUS_FAIL = 3;
  22. const STATUS_DISABLE = 4;
  23. const GENDER_MAN = 1;
  24. const GENDER_WOMAN = 2;
  25. public function getStatusTextAttr($value, $data)
  26. {
  27. return self::STATUS[$data['status']];
  28. }
  29. public function getGenderTextAttr($value, $data)
  30. {
  31. return self::GENDER[$data['gender']];
  32. }
  33. }