<?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('change_to_month') == 'enable' ? '12' : '24-12-2022',
                '1234',
                'dhaka',
                'dhaka',
                'dhaka',
                'Building Name',
                checkSettings('change_to_month') == 'enable' ? '2025' : ''
            ]

        ];

        return collect($data);
    }

    public function headings(): array
    {
        $headings = [
            'ppoe user*',
            'ppoe password*',
            'Name*',
            'Phone No',
            'Packege Name*',
            'Reseller Name*',
            'Zone/Pop*',
            checkSettings('change_to_month') == 'enable' ? 'Expire Date*' : 'Billing Cycle*',
            'Email',
            'Father\'s Name',
            'Mother\'s Name',
            'Area',
            'Mikrotik Comment',
            'Joining Date',
            'Cable Type',
            checkSettings('change_to_month') == 'enable' ? 'expire month*' : 'expire date',
            'customer code',
            'Division',
            'District',
            'Upazila',
            'Building Name',
            checkSettings('change_to_month') == 'enable' ? '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*';
        }
        if(checkSettings('change_to_month') == 'enable'){
            $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
        // ];
    }
}
