Feature #7 : Module Debitur
This commit is contained in:
81
app/Exports/DebitureExport.php
Normal file
81
app/Exports/DebitureExport.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user