dikplhd/app/Imports/DatasetTable36Import.php

55 lines
1.6 KiB
PHP

<?php
namespace App\Imports;
use App\Models\Dataset\DatasetTable36;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithStartRow;
class DatasetTable36Import 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 DatasetTable36([
'dataset_id' => $this->datasetId,
'created_by' => $this->userId,
'golongan' => $row[0],
'nama_lokasi_stasuin' => $row[1],
'lokasi_pemantauan' => $row[2],
'lat' => $row[3],
'long' => $row[4],
'jan' => $row[5],
'feb' => $row[6],
'mar' => $row[7],
'apr' => $row[8],
'mei' => $row[9],
'jun' => $row[10],
'jul' => $row[11],
'agust' => $row[12],
'sept' => $row[13],
'okt' => $row[14],
'nov' => $row[15],
'des' => $row[16],
]);
}
}