HouseApplyRsExport.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 HouseApplyRsExport 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. foreach ($data as $row) {
  26. $family = empty($row->family) ? '' : json_decode($row->family, true);
  27. if (!empty($family)) {
  28. $relation = [];
  29. $child = [];
  30. $id_card = [];
  31. foreach ($family as $v) {
  32. $relation[] = $v['relation'];
  33. $child[] = $v['realname'];
  34. $id_card[] = $v['idcard'];
  35. }
  36. $row['relation'] = implode('/', $relation);
  37. $row['relation_name'] = implode('/', $child);
  38. $row['relation_id_card'] = implode('/', $id_card);
  39. }
  40. $row['status_text'] = $status[$row['rs_check_status']];
  41. $row['check_time'] = $row['rs_check_time'];
  42. $row['check_comment'] = $row['rs_check_comment'];
  43. $row['marry_text'] = $marry[$row['marry']];
  44. }
  45. return view('admin.content.export_house_apply', ['data' => $data]);
  46. }
  47. }