ActivityWorkExcel.php
1.49 KB
<?php
namespace App\Excel;
use App\Enums\ActivityWorkStatusEnum;
use App\Support\ExcelExport;
class ActivityWorkExcel extends ExcelExport
{
protected function beforeHandle(): void
{
$this->builder->with(['user:id,nick_name,real_name,email,company,rate', 'business:id,nick_name,real_name', 'share:id,nick_name,real_name']);
$this->setHeader(['艺名', '真名', '邮箱', '经济公司', '分成模式', '关联队长', '关联分享人', '参与方式', '类型', '状态', '保存/提交时间', 'Demo地址']);
$this->setColumns(['A:K' => 18, 'L:L' => 100]);
}
protected function setData($item): array
{
return [
$item->getRelation('user')?->getAttribute('nick_name'),
$item->getRelation('user')?->getAttribute('real_name'),
$item->getRelation('user')?->getAttribute('email'),
$item->getRelation('user')?->getAttribute('company'),
$item->getRelation('user')?->getAttribute('rate'),
$item->getRelation('business')?->getAttribute('nick_name'),
$item->getRelation('share')?->getAttribute('nick_name'),
$item->getAttribute('mode')?->label(),
$item->getAttribute('type')?->label(),
$item->getAttribute('status')?->label(),
$item->getAttribute('status') === ActivityWorkStatusEnum::SUCCESS ? (string)$item->getAttribute('submit_at') : (string)$item->getAttribute('created_at'),
$item->getAttribute('demo_url'),
];
}
}