I have a problem, I want to update data using Mat website EXCEL laravel, I give condition like this.
Be there excel line called Bujur and Lintang, When the Line is filled will insert to column DB like This
but when Line Bujur and Lintang Not Exists in Excel like this
Column bujur and lintang ini Database will fill NULL value,
when i removed line Lintang and Bujur in EXCEL value bujur and lintang in DB is true fill NULL value, As Expected
the problem here
When I fill Bujur and Lintang in EXCEL, value insert to database keep NULL, same as like I removed Lintang and Bujur in EXCEL,
This is my code
$notExists = array_key_exists('Lintang', $row ) || array_key_exists('Bujur', $row);
if($notExists == FALSE){
Pribadi::updateOrCreate([
'sekolah_id' => $sekolah_id,
'siswa_id' => $siswa->id,
],
[
'sekolah_id' => $sekolah_id,
'siswa_id' => $siswa->id,
'nipd' => $row['NIPD'],
'jenis_tinggal' => $row['Jenis Tinggal'],
'alat_transportasi' => $row['Alat Transportasi'],
'lintang' => NULL,
'bujur' => NULL,
]);
}
elseif($notExists == TRUE){
Pribadi::updateOrCreate([
'sekolah_id' => $sekolah_id,
'siswa_id' => $siswa->id,
],
[
'sekolah_id' => $sekolah_id,
'siswa_id' => $siswa->id,
'nipd' => $row['NIPD'],
'jenis_tinggal' => $row['Jenis Tinggal'],
'alat_transportasi' => $row['Alat Transportasi'],
'lintang' => $row['Lintang'],
'bujur' => $row['Bujur'],
]);
}
the code is when column exists is FALSE( Column and line EXCEL not EXIST) is insert NULL, but when column exists is TRUE( Column and line EXCEL is EXIST) is inserted a value,
but when I fill the column Lintang and Bujur in EXCEL, the value keeps return NULL!
what's wrong in my code? Thanks for your helping.