feat(custom-field): tambahkan fitur custom field
- 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.
This commit is contained in:
49
app/Exports/CustomFieldExport.php
Normal file
49
app/Exports/CustomFieldExport.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user