82 lines
2.3 KiB
PHP
82 lines
2.3 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\Debiture;
|
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
|
|
|
class DebitureExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
|
{
|
|
public function collection()
|
|
{
|
|
return Debiture::with('branch', 'province', 'city', 'district', 'village')->get();
|
|
}
|
|
|
|
public function map($row)
|
|
: array
|
|
{
|
|
return [
|
|
$row->id,
|
|
$row->branch->name .
|
|
$row->cif,
|
|
$row->nomor_rekening,
|
|
$row->name,
|
|
$row->npwp,
|
|
$row->nomor_id,
|
|
$row->email,
|
|
$row->phone,
|
|
$row->province->name,
|
|
$row->city->name,
|
|
$row->district->name,
|
|
$row->village->name,
|
|
$row->postal_code,
|
|
$row->address,
|
|
$row->registered_at,
|
|
$row->created_at
|
|
];
|
|
}
|
|
|
|
public function headings()
|
|
: array
|
|
{
|
|
return [
|
|
'ID',
|
|
'Branch',
|
|
'CIF',
|
|
'Nomor Rekening',
|
|
'Name',
|
|
'NPWP',
|
|
'Nomor ID',
|
|
'Email',
|
|
'Phone',
|
|
'Province',
|
|
'City',
|
|
'District',
|
|
'Village',
|
|
'Postal Code',
|
|
'Address',
|
|
'Registered At',
|
|
'Created At'
|
|
];
|
|
}
|
|
|
|
public function columnFormats()
|
|
: array
|
|
{
|
|
return [
|
|
'A' => NumberFormat::FORMAT_NUMBER,
|
|
'C' => NumberFormat::FORMAT_NUMBER,
|
|
'D' => NumberFormat::FORMAT_NUMBER,
|
|
'F' => NumberFormat::FORMAT_NUMBER,
|
|
'G' => NumberFormat::FORMAT_NUMBER,
|
|
'P' => NumberFormat::FORMAT_DATE_DATETIME,
|
|
'Q' => NumberFormat::FORMAT_DATE_DATETIME
|
|
|
|
];
|
|
}
|
|
}
|