<?php

namespace App\Exports;

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

class ClientsImportSampleFile implements FromCollection, WithHeadings
{
    /**
     * @return \Illuminate\Support\Collection
     */
    public function collection()
    {
        $data = [
            [
                'user1',
                '1234',
                'demo',
                '01700000000',
                '10mb',
                'reseller1',
                'zone1',
                '13',
                'demo@demo.com',
                'F Name',
                'M Name',
                'Area',
                'Mikrotik Comment',
                '24-12-2022',
                'cat6',
                checkSettings('import_excel_requred') == 'enable' ? '12' : '24-12-2022',
                '1234',
                'dhaka',
                'dhaka',
                'dhaka',
                'Building Name',
                '2024'
            ]

        ];

        return collect($data);
    }

    public function headings(): array
    {
        $headings = [
            'ppoe user*',
            'ppoe password*',
            'Name*',
            'Phone No',
            'Packege Name*',
            'Reseller Name*',
            'Zone/Pop*',
            checkSettings('import_excel_requred') == 'enable' ? 'Expire Date*' : 'Billing Cycle*',
            'Email',
            'Father\'s Name',
            'Mother\'s Name',
            'Area',
            'Mikrotik Comment',
            'Joining Date',
            'Cable Type',
            checkSettings('import_excel_requred') == 'enable' ? 'expire month*' : 'expire date',
            'customer code',
            'Division',
            'District',
            'Upazila',
            'Building Name',
            'expire year'
            // Add more headings as needed
        ];

        // Conditionally modify last 3 fields
        if (checkSettings('import_excel_requred') == 'enable') {
            $headings[17] = 'Division*';
            $headings[18] = 'District*';
            $headings[19] = 'Upazila*';
            $headings[21] = 'expire year*';
        }

        return $headings;
        // return [
        //     'ppoe user*',
        //     'ppoe password*',
        //     'Name*',
        //     'Phone No',
        //     'Packege Name*',
        //     'Reseller Name',
        //     'Zone/Pop*',
        //     'Billing Cycle*',
        //     'Email',
        //     'Father\'s Name',
        //     'Mother\'s Name',
        //     'Area',
        //     'Mikrotik Comment',
        //     'Joining Date',
        //     'Cable Type',
        //     'expire date',
        //     'customer code',
        //     'Division',
        //     'District',
        //     'Upazila',
        //     // Add more headings as needed
        // ];
    }
}
