<?php

namespace App\Classes\Modules\Exports\Services;

use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\FromCollection;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Concerns\WithTitle;

class ExportsDeliveryValidValues implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, WithTitle, FromCollection
{
    use Exportable;

    private $request;

    /**
     * ExportsDeliveryValidValues constructor.
     * @param Request $request
     */
    public function __construct(Request $request)
    {
        $this->request = $request;
    }

    public function headings(): array
    {
        return [
            'Types_Of_Services',
            'Service_Type',
            'Mode',
            'Flag',
            'Pickup Address'
        ];
    }

    /**
     * @return \Illuminate\Support\Collection|mixed
     */
    public function collection()
    {
        $returnArray = collect();

        $returnArray->push(['Domestic Shipment', 'Package', 'Pick Up', 'Yes', 'Default']);
        $returnArray->push(['', 'Documents', 'Lodge In / Walk In', 'No', 'Sender']);
        $returnArray->push(['', 'Pallet', '', '', '']);

        return $returnArray;
    }

    public function title(): string
    {
        return 'valid-values';
    }

    /**
     * @param ReturnArray $returnArray
     *
     * @return array
     */
    public function map($returnArray): array
    {
        return [
            $returnArray[0],
            $returnArray[1],
            $returnArray[2],
            $returnArray[3],
            $returnArray[4],
        ];
    }
}