OutRecruitReport.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class OutRecruitReport extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'recruit_id' => 'int',
  10. 'workerid' => 'int',
  11. 'agentid' => 'int',
  12. 'brokerid' => 'int',
  13. 'realname' => 'string',
  14. 'mobile' => 'string',
  15. 'idcard' => 'string',
  16. 'arrivetime' => 'string',
  17. 'status' => 'tinyint',
  18. 'remark' => 'string',
  19. 'retremark' => 'string',
  20. 'createtime' => 'int',
  21. ];
  22. // 设置字段自动转换类型
  23. protected $type = [
  24. 'createtime' => 'timestamp:Y-m-d H:i',
  25. ];
  26. public function getStatusTextAttr($value, $data)
  27. {
  28. $status = [1 => '待审核', 2 => '待面试', 3 => '已入职', 4 => '无效报备'];
  29. return $status[$data['status']];
  30. }
  31. public function getAgeTextAttr($value, $data)
  32. {
  33. $year = substr($data['idcard'], 6, 4);
  34. $monthDay = substr($data['idcard'], 10, 4);
  35. $age = date('Y') - $year;
  36. if ($monthDay > date('md')) {
  37. $age--;
  38. }
  39. return $age;
  40. }
  41. // 关联Comjobs
  42. public function recruit()
  43. {
  44. return $this->hasOne(OutRecruit::class, "id", "recruit_id");
  45. }
  46. // 关联Agent
  47. public function worker()
  48. {
  49. return $this->hasOne(Worker::class, "id", "agentid");
  50. }
  51. // 关联Agent
  52. public function agent()
  53. {
  54. return $this->hasOne(Agent::class, "id", "agentid");
  55. }
  56. // 关联Broker
  57. public function broker()
  58. {
  59. return $this->hasOne(Broker::class, "id", "brokerid");
  60. }
  61. }