Skip to content

Commit 8b79537

Browse files
authored
Automatically use model's primary key if not given
1 parent 491c0d5 commit 8b79537

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/LaravelBatch.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,17 @@ public function __construct(DatabaseManager $db)
4444
*
4545
* @return bool|int
4646
*/
47-
public function update(Model $table, array $values, string $index)
47+
public function update(Model $table, array $values, string $index = null)
4848
{
4949
$final = [];
5050
$ids = [];
5151

5252
if (!count($values)) {
5353
return false;
5454
}
55-
if (!isset($index) && empty($index)) {
56-
return false;
55+
56+
if (!isset($index) || empty($index)) {
57+
$index = $table->getKeyName();
5758
}
5859

5960
foreach ($values as $key => $val) {

0 commit comments

Comments
 (0)