diff --git a/src/Importer/AbstractSpreadsheet.php b/src/Importer/AbstractSpreadsheet.php index d2da518..f1d2fb9 100644 --- a/src/Importer/AbstractSpreadsheet.php +++ b/src/Importer/AbstractSpreadsheet.php @@ -72,11 +72,13 @@ public function getCollection() } else { $data = $this->parser->transform($row, $headers); - if ($this->model) { - $data = $this->model->getQuery()->insert($data); - } + if ($data !== false) { + if ($this->model) { + $data = $this->model->getQuery()->newInstance($data); + } - $collection->push($data); + $collection->push($data); + } } } } @@ -108,12 +110,14 @@ public function save($updateIfEquals = []) $headers = $row; } else { $data = $this->parser->transform($row, $headers); - $when = array_intersect_key($data, $updateIfEquals); - $values = array_diff($data, $when); - if (!empty($when)) { - $this->model->getQuery()->updateOrInsert($when, $values); - } else { - $this->model->getQuery()->insert($values); + if ($data !== false) { + $when = array_intersect_key($data, $updateIfEquals); + $values = array_diff($data, $when); + if (!empty($when)) { + $this->model->getQuery()->updateOrInsert($when, $values); + } else { + $this->model->getQuery()->insert($values); + } } } }