BrokerForm.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class BrokerForm extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'userid' => 'int',
  10. 'workerid' => 'int',
  11. 'agentid' => 'int',
  12. 'title' => 'string',
  13. 'avatar' => 'string',
  14. 'mobile' => 'string',
  15. 'province' => 'string',
  16. 'city' => 'string',
  17. 'district' => 'string',
  18. 'region' => 'string',
  19. 'createtime' => 'int',
  20. 'status' => 'tinyint',
  21. ];
  22. // 设置字段自动转换类型
  23. protected $type = [
  24. 'createtime' => 'timestamp:Y-m-d H:i:s',
  25. ];
  26. public function getStatusTextAttr($value, $data)
  27. {
  28. $status = [1 => '待审核', 2 => '审核通过', 3 => '审核拒绝'];
  29. return $status[$data['status']];
  30. }
  31. // 关联Worker
  32. public function worker()
  33. {
  34. return $this->hasOne(Worker::class, "id", "workerid");
  35. }
  36. // 关联Agent
  37. public function agent()
  38. {
  39. return $this->hasOne(Agent::class, "id", "agentid");
  40. }
  41. }