Files
webstatement/app/Exports/PeriodeStatementExport.php
Daeng Deni Mardaeni 7df50b5141 feat(webstatement): implement periode statement management feature
- Menambahkan menu "Periode Statement" pada module.json dengan akses untuk role administrator.
- Menambahkan model `PeriodeStatement` dengan fitur tracking user dan scoped query.
- Menyediakan controller `PeriodeStatementController` dengan fungsi CRUD, otorisasi, proses, ekspor data ke Excel, dan datatables.
- Menambahkan request validation melalui `PeriodeStatementRequest`.
- Menyediakan view untuk list, create, edit, dan otorisasi periode statement.
- Menambahkan routing termasuk resource routes dan breadcrumbs untuk mendukung fitur ini.
- Menambahkan migrasi database `periode_statements` dengan kolom untuk menyimpan data periode, status, otorisasi, serta metadata.
- Fitur ini memungkinkan pengelolaan dan pemrosesan periode statement secara terstruktur dan aman.

Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
2025-05-11 15:58:49 +07:00

78 lines
2.3 KiB
PHP

<?php
namespace Modules\Webstatement\Exports;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use Modules\Webstatement\Models\PeriodeStatement;
use Carbon\Carbon;
class PeriodeStatementExport implements FromCollection, WithHeadings, WithMapping, WithStyles
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return PeriodeStatement::with('authorizer')->get();
}
/**
* @return array
*/
public function headings(): array
{
return [
'ID',
'Periode',
'Authorization Status',
'Notes',
'Processed At',
'Created By',
'Created At',
'Updated By',
'Updated At',
'Authorized By',
'Authorized At'
];
}
/**
* @param mixed $row
*
* @return array
*/
public function map($row): array
{
return [
$row->id,
$row->periode,
$row->authorized_status,
$row->notes,
$row->processed_at ? Carbon::parse($row->processed_at)->format('Y-m-d H:i:s') : null,
$row->created_by,
$row->created_at ? Carbon::parse($row->created_at)->format('Y-m-d H:i:s') : null,
$row->updated_by,
$row->updated_at ? Carbon::parse($row->updated_at)->format('Y-m-d H:i:s') : null,
$row->authorized_by ? ($row->authorizer ? $row->authorizer->name : $row->authorized_by) : null,
$row->authorized_at ? Carbon::parse($row->authorized_at)->format('Y-m-d H:i:s') : null,
];
}
/**
* @param Worksheet $sheet
*
* @return array
*/
public function styles(Worksheet $sheet)
{
return [
// Style the first row as bold text
1 => ['font' => ['bold' => true]],
];
}
}