<?php

namespace Modules\Lpj\app\Exports;

use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use Modules\Lpj\app\Models\JenisLampiran;

class JenisLampiranExport implements WithColumnFormatting, WithHeadings, FromCollection, WithMapping
{
    public function collection()
    {
        return JenisLampiran::all();
    }

    public function map($row): array
    {
        return [
            $row->id,
            $row->nama,
            $row->deskripsi,
            $row->created_at
        ];
    }

    public function headings(): array
    {
        return [
            'ID',
            'Nama',
            'Deskripsi',
            'Created At'
        ];
    }

    public function columnFormats(): array
    {
        return [
            'A' => NumberFormat::FORMAT_NUMBER,
            'D' => NumberFormat::FORMAT_DATE_DATETIME
        ];
    }
}
