38 lines
942 B
PHP
38 lines
942 B
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use Maatwebsite\Excel\Concerns\FromArray;
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
|
|
class TestLottoCodeList implements FromArray, WithHeadings
|
|
{
|
|
protected $orders;
|
|
public function __construct($orders)
|
|
{
|
|
$this->orders = $orders;
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Support\Collection
|
|
*/
|
|
public function array():array
|
|
{
|
|
$orders = $this->orders;
|
|
$rows = [];
|
|
foreach ($orders as $order)
|
|
{
|
|
$rows[] = [($order['user'])->id, ($order['user'])->name, ($order['user'])->mobile, $order['shop_count']?:"0", $order['code_count']?:"0", $order['refund_order_count']?:"0"];
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
["用户id", "姓名", "手机号", "订单数", "抽奖码数", "含退款订单数"]
|
|
];
|
|
}
|
|
}
|