ResumeExport.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace App\Admin\Exports\Person;
  3. use App\Admin\Exports\RowExport;
  4. class ResumeExport extends RowExport
  5. {
  6. /**
  7. * 设置标题,返回标题数组
  8. * @return array
  9. */
  10. public function headings(): array
  11. {
  12. return [
  13. '编号',
  14. '姓名',
  15. '简历名称',
  16. '公开设置',
  17. '简历完整度',
  18. '审核状态',
  19. '性别',
  20. '年龄',
  21. '现居地',
  22. '户籍',
  23. '婚姻状况',
  24. '工作经验',
  25. '期望岗位性质',
  26. '期望职位',
  27. '期望工作地点',
  28. '期望月薪',
  29. '最高学历',
  30. '毕业院校',
  31. '专业',
  32. '电话',
  33. '邮箱',
  34. '创建时间',
  35. '最后更新时间'
  36. ];
  37. }
  38. /**
  39. * 处理行数据
  40. * @param Model $row
  41. * @return array
  42. */
  43. public function map($row): array
  44. {
  45. $result['id'] = $row->id;
  46. $result['realname'] = $row->memberInfos ? $row->memberInfos->realname : '';
  47. $result['title'] = $row->title;
  48. $result['display'] = $row->display ? '公开' : '保密';
  49. $result['complete_percent'] = $row->complete_percent.'%';
  50. if($row->audit==0){
  51. $audit = '审核未通过';
  52. }elseif ($row->audit==2){
  53. $audit = '审核通过';
  54. }else{
  55. $audit = '等待审核';
  56. }
  57. $result['audit'] = $audit;
  58. $result['sex_cn'] = $row->memberInfos ? $row->memberInfos->sex_cn : '';
  59. $birthday = '';
  60. if($row->memberInfos){
  61. $birthday = date('Y')-$row->memberInfos->birthday;
  62. }
  63. $result['birthday'] = $birthday;
  64. $result['residence_cn'] = $row->memberInfos ? $row->memberInfos->residence_cn : '';
  65. $result['householdaddress_cn'] = $row->memberInfos ? $row->memberInfos->householdaddress_cn : '';
  66. $result['marriage_cn'] = $row->memberInfos ? $row->memberInfos->marriage_cn : '';
  67. $result['experience_cn'] = $row->memberInfos ? $row->memberInfos->experience_cn : '';
  68. $result['nature_cn'] = $row->nature_cn;
  69. $result['intention_jobs'] = $row->intention_jobs;
  70. $result['district_cn'] = $row->district_cn;
  71. $result['wage_cn'] = $row->wage_cn;
  72. $result['education_cn'] = $row->memberInfos ? $row->memberInfos->education_cn : '';
  73. $education = $row->resumeEducation()->orderByRaw('startyear desc, startmonth desc')->first();
  74. $result['school'] = $education ? $education->school : '';
  75. $result['major_cn'] = $row->memberInfos ? $row->memberInfos->major_cn : '';
  76. $result['phone'] = $row->memberInfos ? $row->memberInfos->phone : '';
  77. $result['email'] = $row->memberInfos ? $row->memberInfos->email : '';
  78. $result['created_at'] = $row->created_at;
  79. $result['updated_at'] = $row->updated_at;
  80. return $result;
  81. }
  82. /**
  83. * 设置文件名
  84. * @return string
  85. */
  86. public function getFilename(): string
  87. {
  88. return "resume.xlsx";
  89. }
  90. /**
  91. * 格式化指定列.
  92. * 只有在需要的时候设置,例如在身份证不要显示科学计数时设定列格式:['A'=>NumberFormat::FORMAT_NUMBER]
  93. * @return array
  94. */
  95. public function columnFormats(): array
  96. {
  97. return [
  98. ];
  99. }
  100. }