BrokerForm.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. 'town' => 'string',
  19. 'village' => 'string',
  20. 'region' => 'string',
  21. 'createtime' => 'int',
  22. 'status' => 'tinyint',
  23. ];
  24. // 设置字段自动转换类型
  25. protected $type = [
  26. 'createtime' => 'timestamp:Y-m-d H:i:s',
  27. ];
  28. public function getStatusTextAttr($value, $data)
  29. {
  30. $status = [1 => '待审核', 2 => '审核通过', 3 => '审核拒绝'];
  31. return $status[$data['status']];
  32. }
  33. // 关联Worker
  34. public function worker()
  35. {
  36. return $this->hasOne(Worker::class, "id", "workerid");
  37. }
  38. // 关联Agent
  39. public function agent()
  40. {
  41. return $this->hasOne(Agent::class, "id", "agentid");
  42. }
  43. }