File: D:/HostingSpaces/SBogers10/hours.komma.pro/app/Komma/ExcelExports/Types/HoursExport.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 HoursExport 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 'Uren';
}
public function columnFormats(): array
{
if(!$this->hasRows()) return [];
return [
'J' => NumberFormat::FORMAT_DATE_DDMMYYYY,
];
}
}