Worker.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. use think\model\concern\SoftDelete;
  5. class Worker 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. 'wtype' => 'tinyint',
  15. 'title' => 'string',
  16. 'ftitle' => 'string',
  17. 'tilpic' => 'string',
  18. 'realname' => 'string',
  19. 'mobile' => 'string',
  20. 'weixin' => 'string',
  21. 'latitude' => 'float',
  22. 'longitude' => 'float',
  23. 'province' => 'string',
  24. 'city' => 'string',
  25. 'district' => 'string',
  26. 'address' => 'string',
  27. 'picone' => 'string',
  28. 'pictwo' => 'string',
  29. 'picthr' => 'string',
  30. 'details' => 'string',
  31. 'priority' => 'int',
  32. 'remark' => 'string',
  33. 'status' => 'tinyint',
  34. 'createtime' => 'int',
  35. 'is_public' => 'int',
  36. ];
  37. // 设置字段自动转换类型
  38. protected $type = [
  39. 'createtime' => 'timestamp:Y-m-d H:i:s',
  40. ];
  41. public function getWtypeTextAttr($value, $data)
  42. {
  43. $wtype = [1 => '普通公司', 2 => '派遣公司'];
  44. return $wtype[$data['wtype']];
  45. }
  46. public function getStatusTextAttr($value, $data)
  47. {
  48. $status = [1 => '待审核', 2 => '未通过', 3 => '被禁用', 4 => '升级审核', 5 => '正常中'];
  49. return $status[$data['status']];
  50. }
  51. // 关联User
  52. public function muser()
  53. {
  54. return $this->hasOne(User::class, "id", "userid");
  55. }
  56. // 关联Agent
  57. public function agent()
  58. {
  59. return $this->hasMany(Agent::class, "workerid", "id");
  60. }
  61. // 关联Comjobs
  62. public function comjobs()
  63. {
  64. return $this->hasMany(Comjobs::class, "workerid", "id");
  65. }
  66. // 关联Demand
  67. public function demand()
  68. {
  69. return $this->hasMany(Demand::class, "workerid", "id");
  70. }
  71. }