game2006admin_be/app/Exports/MintExport.php
2022-07-22 19:28:02 +08:00

94 lines
2.2 KiB
PHP

<?php
namespace App\Exports;
use App\Models\MintModel;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Illuminate\Contracts\Support\Responsable;
use Maatwebsite\Excel\Concerns\Exportable;
class MintExport implements FromCollection,WithHeadings,WithMapping,Responsable
{
use Exportable;
protected $data;
private $fileName;
public function __construct( )
{
//实例化该脚本的时候,需要传入要导出的数据
// $this->data = $data;
}
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return MintModel::all();
}
public function array():array
{
return $this->data;
}
public function map($row): array
{
return [
$row['idx'],
$row['unikey'],
$row['account'],
$row['game_id'],
$row['ignore'],
$row['bc_minted'],
$row['bc_mint_txhash'],
$row['bc_mint_itemid'],
$row['bc_mint_tokenid'],
$row['bc_mint_token_type'],
$row['bc_mint_tags'],
$row['bc_mint_count'],
$row['bc_mint_time'],
$row['bc_mint_prepare_block_number'],
$row['bc_mint_success_block_number'],
$row['bc_mint_confirm_time'],
$row['suspend'],
$row['suspend_reason'],
$row['done'],
$row['createtime'],
$row['modifytime'],
];
}
public function headings(): array
{
return [
'idx',
'unikey',
'account',
'game_id',
'ignore',
'bc_minted',
'bc_mint_txhash',
'bc_mint_itemid',
'bc_mint_tokenid',
'bc_mint_token_type',
'bc_mint_tags',
'bc_mint_count',
'bc_mint_time',
'bc_mint_prepare_block_number',
'bc_mint_success_block_number',
'bc_mint_confirm_time',
'suspend',
'suspend_reason',
'done',
'createtime',
'modifytime',
];
}
}