Skip to content

Commit

Permalink
Skip row when parser returns false
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoTod authored Aug 27, 2017
1 parent fc41ddd commit 8cfbf3b
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Importer/AbstractSpreadsheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down

0 comments on commit 8cfbf3b

Please sign in to comment.