Agent.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. use think\model\concern\SoftDelete;
  5. class Agent extends Model
  6. {
  7. use SoftDelete;
  8. protected $deleteTime = 'deletetime';
  9. protected $defaultSoftDelete = 0;
  10. // 设置字段信息
  11. protected $schema = [
  12. 'id' => 'int',
  13. 'userid' => 'int',
  14. 'workerid' => 'int',
  15. 'loginname' => 'string',
  16. 'password' => 'string',
  17. 'idnumber' => 'string',
  18. 'title' => 'string',
  19. 'tilpic' => 'string',
  20. 'picall' => 'string',
  21. 'realname' => 'string',
  22. 'mobile' => 'string',
  23. 'telephone' => 'string',
  24. 'latitude' => 'float',
  25. 'longitude' => 'float',
  26. 'province' => 'string',
  27. 'city' => 'string',
  28. 'district' => 'string',
  29. 'address' => 'string',
  30. 'details' => 'string',
  31. 'priority' => 'int',
  32. 'remark' => 'string',
  33. 'status' => 'tinyint',
  34. 'createtime' => 'int',
  35. 'wxampcode' => 'string'
  36. ];
  37. // 设置字段自动转换类型
  38. protected $type = [
  39. 'picall' => 'json',
  40. 'createtime' => 'timestamp:Y-m-d H:i:s'
  41. ];
  42. protected $jsonAssoc = true;
  43. public function getStatusTextAttr($value,$data)
  44. {
  45. $status = [1=>'正常',2=>'禁用'];
  46. return $status[$data['status']];
  47. }
  48. // 关联User
  49. public function muser()
  50. {
  51. return $this->hasOne(User::class, "id", "userid");
  52. }
  53. // 关联Worker
  54. public function worker()
  55. {
  56. return $this->hasOne(Worker::class, "id", "workerid");
  57. }
  58. // 关联Broker
  59. public function broker()
  60. {
  61. return $this->hasMany(Broker::class, "agentid", "id");
  62. }
  63. // 关联Partjob
  64. public function partjob()
  65. {
  66. return $this->hasMany(Partjob::class, "agentid", "id");
  67. }
  68. }