dikplhd/app/Imports/DatasetTable23Import.php

66 lines
2.2 KiB
PHP

<?php
namespace App\Imports;
use App\Models\Dataset\DatasetTable23;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithStartRow;
class DatasetTable23Import implements ToModel,WithStartRow
{
/**
* @param array $row
*
* @return \Illuminate\Database\Eloquent\Model|null
*/
protected $datasetId;
protected $userId;
public function __construct($datasetId,$userId)
{
$this->datasetId = $datasetId;
$this->userId = $userId;
}
public function startRow(): int
{
return 6;
}
public function model(array $row)
{
return new DatasetTable23([
'dataset_id' => $this->datasetId,
'created_by' => $this->userId,
'lokasi' => $row[0],
'waktu' => $row[1],
'lat' => $row[2],
'long' => $row[3],
'lokasi_sampling' => $row[4],
'warna' => $row[5],
'kecerahan' => $row[6],
'kekeruhan' => $row[7],
'tss' => $row[8],
'sampah' => $row[9],
'lapisan_minyak' => $row[10],
'tempratur' => $row[11],
'ph' => $row[12],
'salinitas' => $row[13],
'do' => $row[14],
'bod5' => $row[15],
'cod' => $row[16],
'amonia_total' => $row[17],
'no2n' => $row[18],
'no3n' => $row[19],
'po4p' => $row[20],
'sianida' => $row[21],
'sulfida' => $row[22],
'klor' => $row[23],
'minyak_bumi' => $row[24],
'fenol' => $row[25],
'pestisida' => $row[26],
'pcb' => $row[27],
]);
}
}