DriverUser.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2020/12/24
  6. * Time: 13:46
  7. */
  8. namespace app\admin\model;
  9. use think\Model;
  10. class DriverUser 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('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  37. }
  38. }