SchoolExport.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 SchoolExport 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. * @param Model $row
  30. * @return array
  31. */
  32. public function map($row): array
  33. {
  34. $result['title'] = $row->name;
  35. $result['major'] = $row->major;
  36. $result['url'] = $row->url;
  37. $result['remarks'] = $row->remarks;
  38. $result['created_at'] = $row->created_at;
  39. $result['introduce'] = strip_tags($row->introduce);
  40. return $result;
  41. }
  42. /**
  43. * 设置文件名
  44. * @return string
  45. */
  46. public function getFilename(): string
  47. {
  48. return "jobfairout_schools.xlsx";
  49. }
  50. /**
  51. * 格式化指定列.
  52. * 只有在需要的时候设置,例如在身份证不要显示科学计数时设定列格式:['A'=>NumberFormat::FORMAT_NUMBER]
  53. * @return array
  54. */
  55. public function columnFormats(): array
  56. {
  57. return [
  58. ];
  59. }
  60. }