JobsExport.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/4/13
  6. * Time: 10:29
  7. */
  8. namespace App\Admin\Exports\Jobfairout;
  9. use App\Admin\Exports\RowExport;
  10. class JobsExport extends RowExport
  11. {
  12. /**
  13. * 设置标题,返回标题数组
  14. * @return array
  15. */
  16. public function headings(): array
  17. {
  18. return [
  19. '职位名称',
  20. '发布公司',
  21. '招聘会标题',
  22. '招聘人数',
  23. '工作地区',
  24. '所属分站',
  25. '性别',
  26. '年龄',
  27. '学历',
  28. '工资',
  29. '单位地址',
  30. '报名时间',
  31. ];
  32. }
  33. /**
  34. * 处理行数据
  35. * @param Model $row
  36. * @return array
  37. */
  38. public function map($row): array
  39. {
  40. static $i=1;
  41. $result['jobs_name'] = $row->jobs_name;
  42. $result['company_name'] = $row->company_name;
  43. $result['title'] = $row->jobfairs->title;
  44. $result['amount'] = empty($row->amount) ? '若干': $row->amount;$row->amount;
  45. $result['district_cn'] = empty($row->district_cn) ? '不限': $row->district_cn;$row->district_cn;
  46. $result['subsite'] = empty($row->jobfairs->sitename->sitename) ? '总站': $row->jobfairs->sitename->sitename;
  47. $result['sex'] = empty($row->sex_cn) ? '不限': $row->sex_cn;
  48. $result['age'] = $row->age == '-'|| empty($row->age) ? '不限' :$row->age;
  49. $result['education'] = empty($row->education_cn) ? '不限': $row->education_cn;
  50. $result['wage_cn'] = empty($row->wage_cn) ? '不限': $row->wage_cn;
  51. $result['address'] = $row->companys->address;
  52. $result['created_at'] = $row->created_at;
  53. $i++;
  54. return $result;
  55. }
  56. /**
  57. * 设置文件名
  58. * @return string
  59. */
  60. public function getFilename(): string
  61. {
  62. return "jobs.xlsx";
  63. }
  64. /**
  65. * 格式化指定列.
  66. * 只有在需要的时候设置,例如在身份证不要显示科学计数时设定列格式:['A'=>NumberFormat::FORMAT_NUMBER]
  67. * @return array
  68. */
  69. public function columnFormats(): array
  70. {
  71. return [
  72. ];
  73. }
  74. }