DriverVerified.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2020/12/2
  6. * Time: 10:09
  7. */
  8. namespace addons\ddrive\model;
  9. use think\Model;
  10. class DriverVerified extends Model
  11. {
  12. // 表名
  13. protected $name = 'driver_verified';
  14. // 自动写入时间戳字段
  15. protected $autoWriteTimestamp = 'int';
  16. // 定义时间戳字段名
  17. protected $createTime = 'createtime';
  18. protected $updateTime = 'updatetime';
  19. protected $deleteTime = false;
  20. // 追加属性
  21. protected $append = [
  22. 'status_text',
  23. ];
  24. public function getStatusList()
  25. {
  26. return ['-1' => __('Status -1'), '0' => __('Status 0'), '1' => __('Status 1')];
  27. }
  28. public function getStatusTextAttr($value, $data)
  29. {
  30. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  31. $list = $this->getStatusList();
  32. return isset($list[$value]) ? $list[$value] : '';
  33. }
  34. public function user()
  35. {
  36. return $this->belongsTo('\\app\\admin\\model\\User', 'user_id', 'id', [], 'LEFT')->field('avatar,group_id,id,username,nickname,email,prevtime,logintime,jointime')->setEagerlyType(0);
  37. }
  38. }