<?php

namespace App\Exports;

use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithStyles;

class LotteryMembersExport implements FromArray,WithHeadings
{
    protected $members;
    public function __construct($members)
    {
        $this->members = $members;
    }

    public function array():array
    {
        $rows = [];
        foreach ($this->members as $member)
        {
            $rows[]= ['user_id'=>$member->user_id, 'name'=>$member->name, 'mobile'=>$member->mobile, 'created_at'=>$member->created_at];
        }
        return $rows;
    }


    public function headings(): array
    {
        return [
            ['用户id', '用户姓名', '手机号', '参加时间']
        ];
    }
}
