123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace App\Admin\Exports\Content;
- use App\Admin\Exports\ViewExport;
- use Illuminate\Contracts\View\View;
- use Illuminate\Support\Collection;
- class HouseApplyRsExport extends ViewExport
- {
- /**
- * 设置文件名
- * @return string
- */
- public function getFilename(): string
- {
- return "house_apply.xlsx";
- }
- /**
- * 渲染对应的视图
- * @param Collection $data 导出的数据
- * @return View
- */
- public function getView(Collection $data): View
- {
- $status = ['未知', '待审核', '审核通过', '审核驳回', '审核不通过'];
- $marry = ['未知', '未婚', '已婚', '离异', '丧偶'];
- $talent_level = ['第一层次' => 1, '第二层次' => 2, '第三层次' => 3, '第四层次' => 4, '第五层次' => 5, '第六层次' => 6, '第七层次' => 7];
- foreach ($data as $row) {
- $family = empty($row->family) ? '' : json_decode($row->family, true);
- if (!empty($family)) {
- $relation = [];
- $child = [];
- $id_card = [];
- foreach ($family as $v) {
- $relation[] = $v['relation'];
- $child[] = $v['realname'];
- $id_card[] = $v['idcard'];
- }
- $row['relation'] = implode('/', $relation);
- $row['relation_name'] = implode('/', $child);
- $row['relation_id_card'] = implode('/', $id_card);
- }
- $row['status_text'] = $status[$row['rs_check_status']];
- $row['check_time'] = $row['rs_check_time'];
- $row['check_comment'] = $row['rs_check_comment'];
- $row['marry_text'] = $marry[$row['marry']];
- $row['level_num'] = $talent_level[$row['talent_level']];
- }
- $data = $data->toArray();
- $level_num = array_column($data, 'level_num');
- array_multisort($level_num, SORT_ASC, $data);
- $no = 1;
- foreach ($data as $k => $row) {
- $data[$k]['no'] = $no;
- $no++;
- }
- return view('admin.content.export_house_apply', ['data' => $data]);
- }
- }
|