update export basic data dan tampilan awal form surveyor
This commit is contained in:
58
app/Exports/BasicDataSurveyorExport.php
Normal file
58
app/Exports/BasicDataSurveyorExport.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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 PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class BasicDataSurveyorExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||
{
|
||||
|
||||
|
||||
protected $model;
|
||||
|
||||
|
||||
public function __construct($model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return $this->model::all();
|
||||
}
|
||||
|
||||
public function map($row)
|
||||
: array
|
||||
{
|
||||
return [
|
||||
$row->id,
|
||||
$row->code,
|
||||
$row->name,
|
||||
$row->created_at
|
||||
];
|
||||
}
|
||||
|
||||
public function headings()
|
||||
: array
|
||||
{
|
||||
return [
|
||||
'ID',
|
||||
'Code',
|
||||
'Name',
|
||||
'Created At'
|
||||
];
|
||||
}
|
||||
|
||||
public function columnFormats()
|
||||
: array
|
||||
{
|
||||
return [
|
||||
'A' => NumberFormat::FORMAT_NUMBER,
|
||||
'D' => NumberFormat::FORMAT_DATE_DATETIME
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user