HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/hours.komma.pro/app/Komma/ExcelExports/Types/ExpensesExport.php
<?php


namespace App\Hours\ExcelExports\Types;


use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithTitle;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;

class ExpensesExport implements FromArray, ShouldAutoSize, WithTitle, WithHeadings, WithColumnFormatting
{

    protected $rows;

    public function __construct(array $rows)
    {
        $this->rows = $rows;
//        dd($rows);
    }


    private function hasRows(): bool
    {
        if(sizeof($this->rows) == 0) return false;
        return true;
    }

    public function headings(): array
    {
        if(!$this->hasRows()) return [];
        return array_keys($this->rows[0]);
    }

    public function array(): array
    {
        return $this->rows;
    }

    /**
     * @return string
     */
    public function title(): string
    {
        return 'Onkosten';
    }

    public function columnFormats(): array
    {
        if(!$this->hasRows()) return [];
        return [
            'J' => NumberFormat::FORMAT_DATE_DDMMYYYY,
        ];
    }
}