ComjobsReport.php 1.5 KB

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