<?php

namespace App\Exports;

use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;


class dashboard_export_reedeem_vouchers implements FromCollection ,  WithHeadings
{
    /**
    * @return \Illuminate\Support\Collection
    */

    protected $redeemedVouchers;

        public function __construct(array $redeemedVouchers)
        {
            $this->redeemedVouchers = collect($redeemedVouchers);
        }

    public function collection()
    {
        // dd($redeemedVouchers);
        return $this->redeemedVouchers->map(function ($transaction) {
            return [
                $transaction['customer']['first_name'],
                $transaction['passport_data']['passport_name'],
                $transaction['passport_vouchers']['coupon_name'],
                $transaction['redeem_date']
            ];
        });
    
    }

    public function headings(): array
    {
        return [
            'Name',
            'Passport Name',
            'Restaurant',
            'Reededm Date'
        ];
    }
}
