<?php

namespace App\Classes\Modules\Reports\ControllersLogic;

use Maatwebsite\Excel\Concerns\FromCollection;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;

class ExportExcelLogic implements FromCollection, ShouldAutoSize, WithHeadings, WithColumnFormatting, WithMapping
{
    private $data;

    public function __construct($data)
    {
        $this->data=$data;
    }
    public function collection()
    {
        return $this->data;
    }
    public function map($order): array
    {
        return [
            (string)$order->reference,
            (string)$order->container_number,
            (string)$order->fulladdress,
            (string)$order->created_at,
            "ssxxx"
        ];
    }

    public function columnFormats(): array
    {
        return [
            'A'=>'@',
            'B' => NumberFormat::FORMAT_DATE_DDMMYYYY,

        ];
    }

    public function headings(): array
    {
        return ["Reference", "Container", "Address", "Created", "Status"];
    }

}
