HouseApplyJcExport.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App\Admin\Exports\Content;
  3. use App\Admin\Exports\ViewExport;
  4. use Illuminate\Contracts\View\View;
  5. use Illuminate\Support\Collection;
  6. class HouseApplyJcExport extends ViewExport
  7. {
  8. /**
  9. * 设置文件名
  10. * @return string
  11. */
  12. public function getFilename(): string
  13. {
  14. return "house_apply.xlsx";
  15. }
  16. /**
  17. * 渲染对应的视图
  18. * @param Collection $data 导出的数据
  19. * @return View
  20. */
  21. public function getView(Collection $data): View
  22. {
  23. $status = ['未知', '待审核', '审核通过', '审核驳回', '审核不通过'];
  24. $marry = ['未知', '未婚', '已婚', '离异', '丧偶'];
  25. $no = 1;
  26. foreach ($data as $row) {
  27. $family = empty($row->family) ? '' : json_decode($row->family, true);
  28. if (!empty($family)) {
  29. $relation = [];
  30. $child = [];
  31. $id_card = [];
  32. foreach ($family as $v) {
  33. $relation[] = $v['relation'];
  34. $child[] = $v['realname'];
  35. $id_card[] = $v['idcard'];
  36. }
  37. $row['relation'] = implode('/', $relation);
  38. $row['relation_name'] = implode('/', $child);
  39. $row['relation_id_card'] = implode('/', $id_card);
  40. }
  41. $row['no'] = $no;
  42. $no++;
  43. $row['status_text'] = $status[$row['rs_check_status']];
  44. $row['check_time'] = $row['rs_check_time'];
  45. $row['check_comment'] = $row['rs_check_comment'];
  46. $row['marry_text'] = $marry[$row['marry']];
  47. }
  48. return view('admin.content.export_house_apply', ['data' => $data]);
  49. }
  50. }