<?php

    namespace Modules\Lpj\Exports;

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

    class StatusPermohonanExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
    {
        public function collection()
        {
            return StatusPermohonan::all();
        }

        public function map($row)
        : array
        {
            return [
                $row->id,
                $row->name,
                $row->slug,
                $row->description,
                $row->status,
                $row->created_at
            ];
        }

        public function headings()
        : array
        {
            return [
                'ID',
                'Name',
                'Slug',
                'Description',
                'Status',
                'Created At'
            ];
        }

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