72 lines
2.4 KiB
PHP
72 lines
2.4 KiB
PHP
<?php
|
|
namespace App\Imports;
|
|
use App\Models\DataUploadBosOmspan;
|
|
use Maatwebsite\Excel\Concerns\ToModel;
|
|
use Maatwebsite\Excel\Concerns\Importable;
|
|
use Maatwebsite\Excel\Concerns\WithStartRow;
|
|
use Maatwebsite\Excel\Concerns\WithSkipDuplicates;
|
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class ImportDataBos implements WithColumnFormatting, ToModel, WithStartRow
|
|
{
|
|
use Importable;
|
|
protected $ta;
|
|
|
|
public function __construct($ta){
|
|
$this->ta = $ta;
|
|
}
|
|
|
|
public function startRow(): int
|
|
{
|
|
return 2;
|
|
}
|
|
|
|
protected function replaceIni($str)
|
|
{
|
|
return str_replace(["'"],"",$str);
|
|
}
|
|
|
|
public function model(array $row)
|
|
{
|
|
$data = [
|
|
"tahun"=>getTA(),
|
|
"no"=>$this->replaceIni($row[0]),
|
|
"kanwil"=>$this->replaceIni($row[1]),
|
|
"kppn"=>$this->replaceIni($row[2]),
|
|
"lokasi_kewenangan"=>$this->replaceIni($row[3]),
|
|
"lokasi_sekolah"=>$this->replaceIni($row[4]),
|
|
"no_tgl_sk"=>$this->replaceIni($row[5]),
|
|
"jenis_bos"=>$this->replaceIni($row[6]),
|
|
"tahap"=>$this->replaceIni($row[7]),
|
|
"gelombang"=>$this->replaceIni($row[8]),
|
|
"npsn_nama_sekolah"=>$this->replaceIni($row[9]),
|
|
"jenis_satuan_pendidikan"=>$this->replaceIni($row[10]),
|
|
"status_sekolah"=>$this->replaceIni($row[11]),
|
|
"bank"=>$this->replaceIni($row[12]),
|
|
"no_rekening_nama_rekening"=>$this->replaceIni($row[13]),
|
|
"npsn"=>$this->replaceIni($row[14]),
|
|
"rekening"=>$this->replaceIni($row[15]),
|
|
"nama"=>$this->replaceIni($row[16]),
|
|
"jenjang_sekolah"=>$this->replaceIni($row[17]),
|
|
"no_tgl_sp2d_detail"=>$this->replaceIni($row[18]),
|
|
"no_sp2d"=>$this->replaceIni($row[19]),
|
|
"tgl_sp2d"=>is_numeric($row[20])?convertSerialDate($row[20]):$row[20],
|
|
"status"=>$this->replaceIni($row[21]),
|
|
"nilai"=>$this->replaceIni($row[22]),
|
|
"pagu"=>$this->replaceIni($row[23]),
|
|
"jmlh_siswa"=>$this->replaceIni($row[24]),
|
|
"ket_retur"=>$this->replaceIni($row[25])
|
|
];
|
|
|
|
return new DataUploadBosOmspan($data);
|
|
}
|
|
|
|
public function columnFormats(): array
|
|
{
|
|
return [
|
|
'Tgl' => NumberFormat::FORMAT_DATE_DDMMYYYY,
|
|
];
|
|
}
|
|
}
|