Skip to content

Commit 8cfbf3b

Browse files
authored
Skip row when parser returns false
1 parent fc41ddd commit 8cfbf3b

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/Importer/AbstractSpreadsheet.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ public function getCollection()
7272
} else {
7373
$data = $this->parser->transform($row, $headers);
7474

75-
if ($this->model) {
76-
$data = $this->model->getQuery()->insert($data);
77-
}
75+
if ($data !== false) {
76+
if ($this->model) {
77+
$data = $this->model->getQuery()->newInstance($data);
78+
}
7879

79-
$collection->push($data);
80+
$collection->push($data);
81+
}
8082
}
8183
}
8284
}
@@ -108,12 +110,14 @@ public function save($updateIfEquals = [])
108110
$headers = $row;
109111
} else {
110112
$data = $this->parser->transform($row, $headers);
111-
$when = array_intersect_key($data, $updateIfEquals);
112-
$values = array_diff($data, $when);
113-
if (!empty($when)) {
114-
$this->model->getQuery()->updateOrInsert($when, $values);
115-
} else {
116-
$this->model->getQuery()->insert($values);
113+
if ($data !== false) {
114+
$when = array_intersect_key($data, $updateIfEquals);
115+
$values = array_diff($data, $when);
116+
if (!empty($when)) {
117+
$this->model->getQuery()->updateOrInsert($when, $values);
118+
} else {
119+
$this->model->getQuery()->insert($values);
120+
}
117121
}
118122
}
119123
}

0 commit comments

Comments
 (0)