提交代码
This commit is contained in:
43
app/Admin/Exporters/CardExporters.php
Normal file
43
app/Admin/Exporters/CardExporters.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Grid\Exporters\CsvExporter;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
|
||||
class CardExporters extends CsvExporter implements WithMapping, WithStrictNullComparison
|
||||
{
|
||||
protected $fileName = '联卡蝠激活卡.csv';
|
||||
protected $mapTrue = true;
|
||||
protected $users = [];
|
||||
public function __construct()
|
||||
{
|
||||
$this->fileName = '联卡蝠激活卡' . date('YmdHis') . '.csv';
|
||||
$this->users = User::pluck('username', 'id')->toArray();
|
||||
}
|
||||
|
||||
protected $headings = ['卡序号', '归属', '卡号', '打印卡号', '卡密', '类型', '专项', '状态', '激活用户', '激活时间', '创建时间', '更改时间'];
|
||||
|
||||
public function map($info): array
|
||||
{
|
||||
$data = [
|
||||
$info->id,
|
||||
$this->users[$info->user_id] ?? '无',
|
||||
'`' . $info->code,
|
||||
$info->type . $info->code,
|
||||
$info->pass,
|
||||
$info->type,
|
||||
$info->type == 'K' ? '商品ID:' . $info->source['goods'] . ';规格ID:' . $info->source['param'] : '非专项',
|
||||
$info->status_text,
|
||||
$this->users[$info->active_id] ?? '无',
|
||||
$info->actived_at,
|
||||
$info->created_at,
|
||||
$info->updated_at,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user