BusinessExcel.php
1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace App\Excel;
use App\Enums\UserSexEnum;
use App\Support\ExcelExport;
use Illuminate\Support\Arr;
class BusinessExcel extends ExcelExport
{
protected function beforeHandle(): void
{
$this->builder->addSelect(['company'])->with(['styleTags:id,name', 'authTags:id,name']);
$this->setHeader([
'用户艺名', '用户真名', '性别', '用户邮箱', '手机号码', '注册时间', '认证通过时间', '用户权限',
'音乐人能力', '是否关注服务号', '公司', '常居地', '擅长的曲风', '状态'
]);
$this->setColumns(['A:N' => 20]);
}
protected function setData($item): array
{
return Arr::map([
$item->getAttribute('nick_name'),
$item->getAttribute('real_name'),
UserSexEnum::tryFrom($item->getAttribute('sex'))?->label(),
$item->getAttribute('email'),
sprintf('(%s)%s', $item->getFullPhone()->getPrefixedIDDCode('+'), $item->getFullPhone()->getNumber()),
(string)$item->getAttribute('created_at'),
(string)$item->getAttribute('audit_at'),
$item->getAttribute('scope')?->label(),
$item->getRelation('authTags')?->implode('name', '|'),
$item->getAttribute('official_status')?->label(),
$item->getAttribute('company'),
$item->getFullAddress(),
$item->getRelation('styleTags')?->implode('name', ','),
$item->getAttribute('status')?->label(),
], static fn($value) => empty($value) ? '无' : $value);
}
}