Skip to content

Commit 0f9b4fb

Browse files
author
Eduardo Haddad
committed
Checks database connection on insert method
1 parent f73313a commit 0f9b4fb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/LaravelBatch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ public function insert(Model $table, array $columns, array $values, int $batchSi
164164
}
165165

166166
if (count($query)) {
167-
return $this->db->transaction(function () use ($totalValues, $totalChunk, $query) {
167+
return $this->db->transaction(function () use ($totalValues, $totalChunk, $query, $table) {
168168

169169
$totalQuery = 0;
170170
foreach ($query as $value) {
171-
$totalQuery += $this->db->statement($value) ? 1 : 0;
171+
$totalQuery += $this->db->connection($this->getConnectionName($table))->statement($value) ? 1 : 0;
172172
}
173173

174174
return [

0 commit comments

Comments
 (0)