Tambah fitur ekspor kalender libur
Menambahkan kelas `HolidayCalendarExport` yang mengimplementasikan berbagai antarmuka dari Maatwebsite Excel untuk mendukung ekspor data kalender libur. Data yang diekspor mencakup ID, tanggal, deskripsi, tipe, dan tanggal pembuatan serta pembaruan dengan format kolom yang sesuai.
This commit is contained in:
52
app/Exports/HolidayCalendarExport.php
Normal file
52
app/Exports/HolidayCalendarExport.php
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Basicdata\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Modules\Basicdata\Entities\HolidayCalendar;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
|
class HolidayCalendarExport implements WithColumnFormatting, WithHeadings, FromCollection, WithMapping
|
||||||
|
{
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return HolidayCalendar::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($row): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$row->id,
|
||||||
|
$row->date,
|
||||||
|
$row->description,
|
||||||
|
$row->type,
|
||||||
|
$row->created_at,
|
||||||
|
$row->updated_at
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Date',
|
||||||
|
'Description',
|
||||||
|
'Type',
|
||||||
|
'Created At',
|
||||||
|
'Updated At'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'B' => NumberFormat::FORMAT_DATE_DDMMYYYY,
|
||||||
|
'E' => NumberFormat::FORMAT_DATE_DATETIME,
|
||||||
|
'F' => NumberFormat::FORMAT_DATE_DATETIME
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user