$row) { // Skip the header row if ($key === 0) { continue; } // Extract data from the current row $number = $row[0]; $subdistrictName = $row[1]; $Altitude = $row[2]; $Rainfall = $row[3]; $SolarRadiation = $row[4]; $PhSoil = $row[5]; $Temperature = $row[6]; $Humidity = $row[7]; // Create or update the Subdistrict $subdistrict = Subdistrict::updateOrCreate([ 'subdistrict' => $subdistrictName, 'altitude' => $Altitude, 'rainfall' => $Rainfall, 'solar_radiation' => $SolarRadiation, 'ph_soil' => $PhSoil, 'temperature' => $Temperature, 'humidity' => $Humidity, ]); } } }