<?php

namespace App\Exports;

use App\EmployeeTest;
use Maatwebsite\Excel\Concerns\FromCollection;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithMapping;
 
 
class Employee_detailsExport implements FromCollection, WithHeadings, ShouldAutoSize, WithMapping,  WithColumnFormatting 

 
{
    /**
    * @return \Illuminate\Support\Collection
    */
    public function collection() {

        return collect(EmployeeTest::getEmployees());
    } 
    
    public function headings(): array
    {
        return [
            'FirstName',
            'LastName',
            'Email',
            'Gender',
            'DateofJoining',
            'YearsofExperience',
        ];
    }
    public function map($EmployeeTest): array
    {
        return [
            $EmployeeTest ->FirstName,
            $EmployeeTest ->LastName,
            $EmployeeTest ->Email,
            $EmployeeTest ->Gender,
            Date::PHPToExcel($EmployeeTest -> DateofJoining),
            $EmployeeTest ->YearsofExperience,
        ];
    }
    public function columnFormats(): array
    {
        return [
            'E' => NumberFormat::FORMAT_DATE_YYYYMMDD2,//dateofjoining column
        ];
    }
}
