- Menambahkan model CustomField dengan atribut mass assignable. - Membuat request validation untuk custom field. - Menambahkan route dan breadcrumb untuk custom field. - Membuat migration untuk tabel custom_fields. - Menambahkan export functionality untuk custom field. - Membuat view untuk menambah dan mengedit custom field.
50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
<?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\CustomField;
|
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
|
|
|
class CustomFieldExport implements WithColumnFormatting, WithHeadings, FromCollection, WithMapping
|
|
{
|
|
public function collection()
|
|
{
|
|
return CustomField::all();
|
|
}
|
|
|
|
public function map($row): array
|
|
{
|
|
return [
|
|
$row->id,
|
|
$row->name,
|
|
$row->type,
|
|
$row->created_at,
|
|
$row->updated_at,
|
|
];
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'ID',
|
|
'Name',
|
|
'Type',
|
|
'Created At',
|
|
'Updated At',
|
|
];
|
|
}
|
|
|
|
public function columnFormats(): array
|
|
{
|
|
return [
|
|
'A' => NumberFormat::FORMAT_NUMBER,
|
|
'D' => NumberFormat::FORMAT_DATE_DDMMYYYY,
|
|
'E' => NumberFormat::FORMAT_DATE_DDMMYYYY,
|
|
];
|
|
}
|
|
}
|